bevy_render/camera/clear_color.rs
1use crate::extract_resource::ExtractResource;
2use bevy_color::Color;
3use bevy_derive::{Deref, DerefMut};
4use bevy_ecs::prelude::*;
5use bevy_reflect::prelude::*;
6use derive_more::derive::From;
7use serde::{Deserialize, Serialize};
8
9/// For a camera, specifies the color used to clear the viewport before rendering.
10#[derive(Reflect, Serialize, Deserialize, Copy, Clone, Debug, Default, From)]
11#[reflect(Serialize, Deserialize, Default)]
12pub enum ClearColorConfig {
13 /// The clear color is taken from the world's [`ClearColor`] resource.
14 #[default]
15 Default,
16 /// The given clear color is used, overriding the [`ClearColor`] resource defined in the world.
17 Custom(Color),
18 /// No clear color is used: the camera will simply draw on top of anything already in the viewport.
19 ///
20 /// This can be useful when multiple cameras are rendering to the same viewport.
21 None,
22}
23
24/// A [`Resource`] that stores the color that is used to clear the screen between frames.
25///
26/// This color appears as the "background" color for simple apps,
27/// when there are portions of the screen with nothing rendered.
28#[derive(Resource, Clone, Debug, Deref, DerefMut, ExtractResource, Reflect)]
29#[reflect(Resource, Default, Debug)]
30pub struct ClearColor(pub Color);
31
32/// Match the dark gray bevy website code block color by default.
33impl Default for ClearColor {
34 fn default() -> Self {
35 Self(Color::srgb_u8(43, 44, 47))
36 }
37}