move color constants to Color struct
This commit is contained in:
parent
dcc34473e5
commit
f5149cab05
@ -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 }
|
||||
}
|
||||
@ -132,13 +138,3 @@ impl GetBytes for ColorSource {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@ -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<Texture>) -> Self {
|
||||
ColorMaterial {
|
||||
color: colors::WHITE,
|
||||
color: Color::WHITE,
|
||||
texture: Some(texture),
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user