From c2ae51d13a012df0ed2cca0389511e91a323fc95 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Tue, 27 Feb 2024 20:29:49 -0500 Subject: [PATCH] Re-export `basic` color palette via `css` color palette (#12172) # Objective The `css` contains all of the `basic` colors. Rather than defining them twice, we can re-export them. Suggested by @viridia <3 ## Solution - Re-export basic color palette within the css color palette. - Remove the duplicate colors - Fix alphabetization of the basic color palette file while I'm here --------- Co-authored-by: Alice Cecile --- crates/bevy_color/src/palettes/basic.rs | 4 +-- crates/bevy_color/src/palettes/css.rs | 34 +++---------------------- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/crates/bevy_color/src/palettes/basic.rs b/crates/bevy_color/src/palettes/basic.rs index e1f1c532592ea..80b9d28e8c11a 100644 --- a/crates/bevy_color/src/palettes/basic.rs +++ b/crates/bevy_color/src/palettes/basic.rs @@ -11,12 +11,12 @@ pub const BLACK: Srgba = Srgba::new(0.0, 0.0, 0.0, 1.0); pub const BLUE: Srgba = Srgba::new(0.0, 0.0, 1.0, 1.0); ///
pub const CYAN: Srgba = Srgba::new(0.0, 1.0, 1.0, 1.0); -///
-pub const GREEN: Srgba = Srgba::new(0.0, 0.5, 0.0, 1.0); ///
pub const FUCHSIA: Srgba = Srgba::new(1.0, 0.0, 1.0, 1.0); ///
pub const GRAY: Srgba = Srgba::new(0.5, 0.5, 0.5, 1.0); +///
+pub const GREEN: Srgba = Srgba::new(0.0, 0.5, 0.0, 1.0); ///
pub const LIME: Srgba = Srgba::new(0.0, 1.0, 0.0, 1.0); ///
diff --git a/crates/bevy_color/src/palettes/css.rs b/crates/bevy_color/src/palettes/css.rs index 7cd08d5216b55..88391fac3db21 100644 --- a/crates/bevy_color/src/palettes/css.rs +++ b/crates/bevy_color/src/palettes/css.rs @@ -3,6 +3,10 @@ use crate::Srgba; +// The CSS4 colors are a superset of the CSS1 colors, so we can just re-export the CSS1 colors. +#[allow(unused_imports)] +pub use crate::palettes::basic::*; + ///
pub const ALICE_BLUE: Srgba = Srgba::new(0.941, 0.973, 1.0, 1.0); ///
@@ -17,12 +21,8 @@ pub const AZURE: Srgba = Srgba::new(0.941, 1.0, 1.0, 1.0); pub const BEIGE: Srgba = Srgba::new(0.961, 0.961, 0.863, 1.0); ///
pub const BISQUE: Srgba = Srgba::new(1.0, 0.894, 0.769, 1.0); -///
-pub const BLACK: Srgba = Srgba::new(0.0, 0.0, 0.0, 1.0); ///
pub const BLANCHED_ALMOND: Srgba = Srgba::new(1.0, 0.922, 0.804, 1.0); -///
-pub const BLUE: Srgba = Srgba::new(0.0, 0.0, 1.0, 1.0); ///
pub const BLUE_VIOLET: Srgba = Srgba::new(0.541, 0.169, 0.886, 1.0); ///
@@ -43,8 +43,6 @@ pub const CORNFLOWER_BLUE: Srgba = Srgba::new(0.392, 0.584, 0.929, 1.0); pub const CORNSILK: Srgba = Srgba::new(1.0, 0.973, 0.863, 1.0); ///
pub const CRIMSON: Srgba = Srgba::new(0.863, 0.078, 0.235, 1.0); -///
-pub const CYAN: Srgba = Srgba::new(0.0, 1.0, 1.0, 1.0); ///
pub const DARK_BLUE: Srgba = Srgba::new(0.0, 0.0, 0.545, 1.0); ///
@@ -99,8 +97,6 @@ pub const FIRE_BRICK: Srgba = Srgba::new(0.698, 0.133, 0.133, 1.0); pub const FLORAL_WHITE: Srgba = Srgba::new(1.0, 0.98, 0.941, 1.0); ///
pub const FOREST_GREEN: Srgba = Srgba::new(0.133, 0.545, 0.133, 1.0); -///
-pub const FUCHSIA: Srgba = Srgba::new(1.0, 0.0, 1.0, 1.0); ///
pub const GAINSBORO: Srgba = Srgba::new(0.863, 0.863, 0.863, 1.0); ///
@@ -109,8 +105,6 @@ pub const GHOST_WHITE: Srgba = Srgba::new(0.973, 0.973, 1.0, 1.0); pub const GOLD: Srgba = Srgba::new(1.0, 0.843, 0.0, 1.0); ///
pub const GOLDENROD: Srgba = Srgba::new(0.855, 0.647, 0.125, 1.0); -///
-pub const GRAY: Srgba = Srgba::new(0.502, 0.502, 0.502, 1.0); ///
pub const GREEN: Srgba = Srgba::new(0.0, 0.502, 0.0, 1.0); ///
@@ -167,16 +161,12 @@ pub const LIGHT_SLATE_GREY: Srgba = Srgba::new(0.467, 0.533, 0.6, 1.0); pub const LIGHT_STEEL_BLUE: Srgba = Srgba::new(0.69, 0.769, 0.871, 1.0); ///
pub const LIGHT_YELLOW: Srgba = Srgba::new(1.0, 1.0, 0.878, 1.0); -///
-pub const LIME: Srgba = Srgba::new(0.0, 1.0, 0.0, 1.0); ///
pub const LIMEGREEN: Srgba = Srgba::new(0.196, 0.804, 0.196, 1.0); ///
pub const LINEN: Srgba = Srgba::new(0.98, 0.941, 0.902, 1.0); ///
pub const MAGENTA: Srgba = Srgba::new(1.0, 0.0, 1.0, 1.0); -///
-pub const MAROON: Srgba = Srgba::new(0.502, 0.0, 0.0, 1.0); ///
pub const MEDIUM_AQUAMARINE: Srgba = Srgba::new(0.4, 0.804, 0.667, 1.0); ///
@@ -205,12 +195,8 @@ pub const MISTY_ROSE: Srgba = Srgba::new(1.0, 0.894, 0.882, 1.0); pub const MOCCASIN: Srgba = Srgba::new(1.0, 0.894, 0.71, 1.0); ///
pub const NAVAJO_WHITE: Srgba = Srgba::new(1.0, 0.871, 0.678, 1.0); -///
-pub const NAVY: Srgba = Srgba::new(0.0, 0.0, 0.502, 1.0); ///
pub const OLD_LACE: Srgba = Srgba::new(0.992, 0.961, 0.902, 1.0); -///
-pub const OLIVE: Srgba = Srgba::new(0.502, 0.502, 0.0, 1.0); ///
pub const OLIVE_DRAB: Srgba = Srgba::new(0.42, 0.557, 0.137, 1.0); ///
@@ -239,12 +225,8 @@ pub const PINK: Srgba = Srgba::new(1.0, 0.753, 0.796, 1.0); pub const PLUM: Srgba = Srgba::new(0.867, 0.627, 0.867, 1.0); ///
pub const POWDER_BLUE: Srgba = Srgba::new(0.69, 0.878, 0.902, 1.0); -///
-pub const PURPLE: Srgba = Srgba::new(0.502, 0.0, 0.502, 1.0); ///
pub const REBECCA_PURPLE: Srgba = Srgba::new(0.4, 0.2, 0.6, 1.0); -///
-pub const RED: Srgba = Srgba::new(1.0, 0.0, 0.0, 1.0); ///
pub const ROSY_BROWN: Srgba = Srgba::new(0.737, 0.561, 0.561, 1.0); ///
@@ -261,8 +243,6 @@ pub const SEA_GREEN: Srgba = Srgba::new(0.18, 0.545, 0.341, 1.0); pub const SEASHELL: Srgba = Srgba::new(1.0, 0.961, 0.933, 1.0); ///
pub const SIENNA: Srgba = Srgba::new(0.627, 0.322, 0.176, 1.0); -///
-pub const SILVER: Srgba = Srgba::new(0.753, 0.753, 0.753, 1.0); ///
pub const SKY_BLUE: Srgba = Srgba::new(0.529, 0.808, 0.922, 1.0); ///
@@ -279,8 +259,6 @@ pub const SPRING_GREEN: Srgba = Srgba::new(0.0, 1.0, 0.498, 1.0); pub const STEEL_BLUE: Srgba = Srgba::new(0.275, 0.51, 0.706, 1.0); ///
pub const TAN: Srgba = Srgba::new(0.824, 0.706, 0.549, 1.0); -///
-pub const TEAL: Srgba = Srgba::new(0.0, 0.502, 0.502, 1.0); ///
pub const THISTLE: Srgba = Srgba::new(0.847, 0.749, 0.847, 1.0); ///
@@ -291,11 +269,7 @@ pub const TURQUOISE: Srgba = Srgba::new(0.251, 0.878, 0.816, 1.0); pub const VIOLET: Srgba = Srgba::new(0.933, 0.51, 0.933, 1.0); ///
pub const WHEAT: Srgba = Srgba::new(0.961, 0.871, 0.702, 1.0); -///
-pub const WHITE: Srgba = Srgba::new(1.0, 1.0, 1.0, 1.0); ///
pub const WHITE_SMOKE: Srgba = Srgba::new(0.961, 0.961, 0.961, 1.0); -///
-pub const YELLOW: Srgba = Srgba::new(1.0, 1.0, 0.0, 1.0); ///
pub const YELLOW_GREEN: Srgba = Srgba::new(0.604, 0.804, 0.196, 1.0);