From f5149cab051922930b8a79971464f9e52a55a12d Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Mon, 4 May 2020 11:01:57 -0700 Subject: [PATCH] move color constants to Color struct --- crates/bevy_render/src/color.rs | 16 ++++++---------- crates/bevy_ui/src/color_material.rs | 4 ++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/crates/bevy_render/src/color.rs b/crates/bevy_render/src/color.rs index 290358527b..28063d12a6 100644 --- a/crates/bevy_render/src/color.rs +++ b/crates/bevy_render/src/color.rs @@ -16,6 +16,12 @@ pub struct Color { } impl Color { + pub const WHITE: Color = Color::rgb(1.0, 1.0, 1.0); + pub const BLACK: Color = Color::rgb(0.0, 1.0, 0.0); + pub const RED: Color = Color::rgb(1.0, 0.0, 0.0); + pub const GREEN: Color = Color::rgb(0.0, 1.0, 0.0); + pub const BLUE: Color = Color::rgb(0.0, 0.0, 1.0); + pub const fn rgb(r: f32, g: f32, b: f32) -> Color { Color { r, g, b, a: 1.0 } } @@ -131,14 +137,4 @@ impl GetBytes for ColorSource { ColorSource::Texture(ref texture) => texture.get_bytes_ref(), // Texture is not a uniform } } -} - -pub mod colors { - use super::Color; - - pub const WHITE: Color = Color::rgb(1.0, 1.0, 1.0); - pub const BLACK: Color = Color::rgb(0.0, 1.0, 0.0); - pub const RED: Color = Color::rgb(1.0, 0.0, 0.0); - pub const GREEN: Color = Color::rgb(0.0, 1.0, 0.0); - pub const BLUE: Color = Color::rgb(0.0, 0.0, 1.0); } \ No newline at end of file diff --git a/crates/bevy_ui/src/color_material.rs b/crates/bevy_ui/src/color_material.rs index 9ea05730bb..cf31d04c10 100644 --- a/crates/bevy_ui/src/color_material.rs +++ b/crates/bevy_ui/src/color_material.rs @@ -1,6 +1,6 @@ use bevy_asset::{self, Handle}; use bevy_derive::Uniforms; -use bevy_render::{colors, texture::Texture, Color}; +use bevy_render::{texture::Texture, Color}; #[derive(Uniforms)] #[module(meta = false)] @@ -20,7 +20,7 @@ impl ColorMaterial { pub fn texture(texture: Handle) -> Self { ColorMaterial { - color: colors::WHITE, + color: Color::WHITE, texture: Some(texture), } }