Fix example colors (#672)

This commit is contained in:
Carter Anderson 2020-10-12 16:54:22 -07:00 committed by GitHub
parent 930eba4ccd
commit 5e7c36d1c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 32 additions and 38 deletions

View file

@ -90,6 +90,10 @@ impl Plugin for RenderPlugin {
app.add_asset_loader::<Texture, HdrTextureLoader>();
}
if app.resources().get::<ClearColor>().is_none() {
app.resources_mut().insert(ClearColor::default());
}
app.add_stage_after(bevy_asset::stage::ASSET_EVENTS, stage::RENDER_RESOURCE)
.add_stage_after(stage::RENDER_RESOURCE, stage::RENDER_GRAPH_SYSTEMS)
.add_stage_after(stage::RENDER_GRAPH_SYSTEMS, stage::DRAW)

View file

@ -23,7 +23,7 @@ pub struct ClearColor(pub Color);
impl Default for ClearColor {
fn default() -> Self {
Self(Color::rgb(0.1, 0.1, 0.1))
Self(Color::rgb(0.4, 0.4, 0.4))
}
}

View file

@ -19,26 +19,16 @@ fn setup(
// plane
.spawn(PbrComponents {
mesh: meshes.add(Mesh::from(shape::Plane { size: 10.0 })),
material: materials.add(Color::rgb(0.1, 0.2, 0.1).into()),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
..Default::default()
})
// cube
.spawn(PbrComponents {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.5, 0.4, 0.3).into()),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
transform: Transform::from_translation(Vec3::new(0.0, 1.0, 0.0)),
..Default::default()
})
// sphere
.spawn(PbrComponents {
mesh: meshes.add(Mesh::from(shape::Icosphere {
subdivisions: 4,
radius: 0.5,
})),
material: materials.add(Color::rgb(0.1, 0.4, 0.8).into()),
transform: Transform::from_translation(Vec3::new(1.5, 1.5, 1.5)),
..Default::default()
})
// light
.spawn(LightComponents {
transform: Transform::from_translation(Vec3::new(4.0, 8.0, 4.0)),

View file

@ -22,7 +22,7 @@ fn setup(
.load("assets/models/monkey/Monkey.gltf")
.unwrap(),
// create a material for the mesh
material: materials.add(Color::rgb(0.5, 0.4, 0.3).into()),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
transform: Transform::from_translation(Vec3::new(-1.5, 0.0, 0.0)),
..Default::default()
})
@ -33,7 +33,7 @@ fn setup(
.load("assets/models/monkey/Monkey.glb")
.unwrap(),
// create a material for the mesh
material: materials.add(Color::rgb(0.5, 0.4, 0.3).into()),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
transform: Transform::from_translation(Vec3::new(1.5, 0.0, 0.0)),
..Default::default()
})

View file

@ -22,7 +22,7 @@ fn setup(
// cube
.spawn(PbrComponents {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.5, 0.4, 0.3).into()),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
..Default::default()
})
// light

View file

@ -29,7 +29,7 @@ fn setup(
) {
let cube_handle = meshes.add(Mesh::from(shape::Cube { size: 1.0 }));
let cube_material_handle = materials.add(StandardMaterial {
albedo: Color::rgb(0.5, 0.4, 0.3),
albedo: Color::rgb(0.8, 0.7, 0.6),
..Default::default()
});

View file

@ -39,7 +39,7 @@ fn setup(
// You can also add assets directly to their Assets<T> storage:
let material_handle = materials.add(StandardMaterial {
albedo: Color::rgb(0.5, 0.4, 0.3),
albedo: Color::rgb(0.8, 0.7, 0.6),
..Default::default()
});

View file

@ -28,7 +28,7 @@ fn setup(
// Create a material for the mesh:
let material_handle = materials.add(StandardMaterial {
albedo: Color::rgb(0.5, 0.4, 0.3),
albedo: Color::rgb(0.8, 0.7, 0.6),
..Default::default()
});

View file

@ -9,7 +9,7 @@ fn main() {
App::build()
.add_default_plugins()
.add_resource(Scoreboard { score: 0 })
.add_resource(ClearColor(Color::rgb(0.7, 0.7, 0.7)))
.add_resource(ClearColor(Color::rgb(0.9, 0.9, 0.9)))
.add_startup_system(setup.system())
.add_system(paddle_movement_system.system())
.add_system(ball_collision_system.system())
@ -47,7 +47,7 @@ fn setup(
.spawn(UiCameraComponents::default())
// paddle
.spawn(SpriteComponents {
material: materials.add(Color::rgb(0.2, 0.2, 0.8).into()),
material: materials.add(Color::rgb(0.5, 0.5, 1.0).into()),
transform: Transform::from_translation(Vec3::new(0.0, -215.0, 0.0)),
sprite: Sprite::new(Vec2::new(120.0, 30.0)),
..Default::default()
@ -56,7 +56,7 @@ fn setup(
.with(Collider::Solid)
// ball
.spawn(SpriteComponents {
material: materials.add(Color::rgb(0.8, 0.2, 0.2).into()),
material: materials.add(Color::rgb(1.0, 0.5, 0.5).into()),
transform: Transform::from_translation(Vec3::new(0.0, -50.0, 1.0)),
sprite: Sprite::new(Vec2::new(30.0, 30.0)),
..Default::default()
@ -70,7 +70,7 @@ fn setup(
font: asset_server.load("assets/fonts/FiraSans-Bold.ttf").unwrap(),
value: "Score:".to_string(),
style: TextStyle {
color: Color::rgb(0.2, 0.2, 0.8),
color: Color::rgb(0.5, 0.5, 1.0),
font_size: 40.0,
},
},
@ -87,7 +87,7 @@ fn setup(
});
// Add walls
let wall_material = materials.add(Color::rgb(0.5, 0.5, 0.5).into());
let wall_material = materials.add(Color::rgb(0.8, 0.8, 0.8).into());
let wall_thickness = 10.0;
let bounds = Vec2::new(900.0, 600.0);
@ -133,7 +133,7 @@ fn setup(
let bricks_width = brick_columns as f32 * (brick_size.x() + brick_spacing) - brick_spacing;
// center the bricks and move them up a bit
let bricks_offset = Vec3::new(-(bricks_width - brick_size.x()) / 2.0, 100.0, 0.0);
let brick_material = materials.add(Color::rgb(0.5, 0.5, 1.0).into());
for row in 0..brick_rows {
let y_position = row as f32 * (brick_size.y() + brick_spacing);
for column in 0..brick_columns {
@ -145,7 +145,7 @@ fn setup(
commands
// brick
.spawn(SpriteComponents {
material: materials.add(Color::rgb(0.2, 0.2, 0.8).into()),
material: brick_material,
sprite: Sprite::new(brick_size),
transform: Transform::from_translation(brick_position),
..Default::default()

View file

@ -20,9 +20,9 @@ impl FromResources for ButtonMaterials {
fn from_resources(resources: &Resources) -> Self {
let mut materials = resources.get_mut::<Assets<ColorMaterial>>().unwrap();
ButtonMaterials {
normal: materials.add(Color::rgb(0.02, 0.02, 0.02).into()),
hovered: materials.add(Color::rgb(0.05, 0.05, 0.05).into()),
pressed: materials.add(Color::rgb(0.1, 0.5, 0.1).into()),
normal: materials.add(Color::rgb(0.15, 0.15, 0.15).into()),
hovered: materials.add(Color::rgb(0.25, 0.25, 0.25).into()),
pressed: materials.add(Color::rgb(0.35, 0.75, 0.35).into()),
}
}
}
@ -85,7 +85,7 @@ fn setup(
font: asset_server.load("assets/fonts/FiraSans-Bold.ttf").unwrap(),
style: TextStyle {
font_size: 40.0,
color: Color::rgb(0.8, 0.8, 0.8),
color: Color::rgb(0.9, 0.9, 0.9),
},
},
..Default::default()

View file

@ -35,7 +35,7 @@ fn setup(
border: Rect::all(Val::Px(2.0)),
..Default::default()
},
material: materials.add(Color::rgb(0.4, 0.4, 0.4).into()),
material: materials.add(Color::rgb(0.65, 0.65, 0.65).into()),
..Default::default()
})
.with_children(|parent| {
@ -47,7 +47,7 @@ fn setup(
align_items: AlignItems::FlexEnd,
..Default::default()
},
material: materials.add(Color::rgb(0.02, 0.02, 0.02).into()),
material: materials.add(Color::rgb(0.15, 0.15, 0.15).into()),
..Default::default()
})
.with_children(|parent| {
@ -77,7 +77,7 @@ fn setup(
size: Size::new(Val::Px(200.0), Val::Percent(100.0)),
..Default::default()
},
material: materials.add(Color::rgb(0.02, 0.02, 0.02).into()),
material: materials.add(Color::rgb(0.15, 0.15, 0.15).into()),
..Default::default()
})
// absolute positioning
@ -93,7 +93,7 @@ fn setup(
border: Rect::all(Val::Px(20.0)),
..Default::default()
},
material: materials.add(Color::rgb(0.1, 0.1, 1.0).into()),
material: materials.add(Color::rgb(0.4, 0.4, 1.0).into()),
..Default::default()
})
.with_children(|parent| {
@ -102,7 +102,7 @@ fn setup(
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
..Default::default()
},
material: materials.add(Color::rgb(0.6, 0.6, 1.0).into()),
material: materials.add(Color::rgb(0.8, 0.8, 1.0).into()),
..Default::default()
});
})

View file

@ -2,7 +2,7 @@ use bevy::{prelude::*, render::pass::ClearColor};
fn main() {
App::build()
.add_resource(ClearColor(Color::rgb(0.2, 0.2, 0.8)))
.add_resource(ClearColor(Color::rgb(0.5, 0.5, 0.9)))
.add_default_plugins()
.run();
}

View file

@ -74,7 +74,7 @@ fn setup(
TextureAttachment::Input("color_attachment".to_string()),
TextureAttachment::Input("color_resolve_target".to_string()),
Operations {
load: LoadOp::Clear(Color::rgb(0.1, 0.1, 0.3)),
load: LoadOp::Clear(Color::rgb(0.5, 0.5, 0.8)),
store: true,
},
)],
@ -159,7 +159,7 @@ fn setup(
// create a material for the mesh
let material_handle = materials.add(StandardMaterial {
albedo: Color::rgb(0.5, 0.4, 0.3),
albedo: Color::rgb(0.8, 0.7, 0.6),
..Default::default()
});