Skip to content

Commit 73bb310

Browse files
torsteingrindvikTorstein Grindvik
andauthored
impl From<Color> for ClearColorConfig (#10734)
# Objective I tried setting `ClearColorConfig` in my app via `Color::FOO.into()` expecting it to work, but the impl was missing. ## Solution - Add `impl From<Color> for ClearColorConfig` - Change examples to use this impl ## Changelog ### Added - `ClearColorConfig` can be constructed via `.into()` on a `Color` --------- Signed-off-by: Torstein Grindvik <torstein.grindvik@muybridge.com> Co-authored-by: Torstein Grindvik <torstein.grindvik@muybridge.com>
1 parent 4788315 commit 73bb310

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

crates/bevy_core_pipeline/src/clear_color.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ pub enum ClearColorConfig {
1919
None,
2020
}
2121

22+
impl From<Color> for ClearColorConfig {
23+
fn from(color: Color) -> Self {
24+
Self::Custom(color)
25+
}
26+
}
27+
2228
/// A [`Resource`] that stores the color that is used to clear the screen between frames.
2329
///
2430
/// This color appears as the "background" color for simple apps,

examples/3d/render_to_texture.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use std::f32::consts::PI;
44

55
use bevy::{
6-
core_pipeline::clear_color::ClearColorConfig,
76
prelude::*,
87
render::{
98
camera::RenderTarget,
@@ -97,7 +96,7 @@ fn setup(
9796
commands.spawn((
9897
Camera3dBundle {
9998
camera_3d: Camera3d {
100-
clear_color: ClearColorConfig::Custom(Color::WHITE),
99+
clear_color: Color::WHITE.into(),
101100
..default()
102101
},
103102
camera: Camera {

examples/shader/post_processing.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
//! This is a fairly low level example and assumes some familiarity with rendering concepts and wgpu.
77
88
use bevy::{
9-
core_pipeline::{
10-
clear_color::ClearColorConfig, core_3d,
11-
fullscreen_vertex_shader::fullscreen_shader_vertex_state,
12-
},
9+
core_pipeline::{core_3d, fullscreen_vertex_shader::fullscreen_shader_vertex_state},
1310
ecs::query::QueryItem,
1411
prelude::*,
1512
render::{
@@ -330,7 +327,7 @@ fn setup(
330327
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 5.0))
331328
.looking_at(Vec3::default(), Vec3::Y),
332329
camera_3d: Camera3d {
333-
clear_color: ClearColorConfig::Custom(Color::WHITE),
330+
clear_color: Color::WHITE.into(),
334331
..default()
335332
},
336333
..default()

0 commit comments

Comments
 (0)