From c630b713cb19460cc750f71a45505df2c5f81707 Mon Sep 17 00:00:00 2001 From: Rob Parrett Date: Tue, 5 Mar 2024 16:42:03 -0700 Subject: [PATCH] Fix green colors becoming darker in various examples (#12328) # Objective Fixes #12225 Prior to the `bevy_color` port, `GREEN` used to mean "full green." But it is now a much darker color matching the css1 spec. ## Solution Change usages of `basic::GREEN` or `css::GREEN` to `LIME` to restore the examples to their former colors. This also removes the duplicate definition of `GREEN` from `css`. (it was already re-exported from `basic`) ## Note A lot of these examples could use nicer colors. I'm not trying to do that here. "Dark Grey" will be tackled separately and has its own tracking issue. --- crates/bevy_color/src/palettes/css.rs | 2 -- examples/2d/bounding_2d.rs | 10 +++------- examples/2d/text2d.rs | 2 +- examples/3d/lighting.rs | 4 ++-- examples/3d/shadow_caster_receiver.rs | 4 ++-- examples/3d/transmission.rs | 2 +- examples/3d/wireframe.rs | 10 ++++------ examples/audio/spatial_audio_2d.rs | 2 +- examples/audio/spatial_audio_3d.rs | 4 ++-- examples/ecs/hierarchy.rs | 2 +- examples/games/game_menu.rs | 4 ++-- examples/gizmos/2d_gizmos.rs | 4 ++-- examples/gizmos/3d_gizmos.rs | 2 +- examples/stress_tests/bevymark.rs | 8 ++++---- examples/ui/text_debug.rs | 2 +- examples/ui/ui.rs | 4 ++-- examples/ui/viewport_debug.rs | 2 +- examples/ui/z_index.rs | 4 ++-- examples/window/low_power.rs | 4 ++-- 19 files changed, 34 insertions(+), 42 deletions(-) diff --git a/crates/bevy_color/src/palettes/css.rs b/crates/bevy_color/src/palettes/css.rs index 88391fac3db217..0c1e073bec4b62 100644 --- a/crates/bevy_color/src/palettes/css.rs +++ b/crates/bevy_color/src/palettes/css.rs @@ -106,8 +106,6 @@ 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 GREEN: Srgba = Srgba::new(0.0, 0.502, 0.0, 1.0); -///
pub const GREEN_YELLOW: Srgba = Srgba::new(0.678, 1.0, 0.184, 1.0); ///
pub const GREY: Srgba = Srgba::new(0.502, 0.502, 0.502, 1.0); diff --git a/examples/2d/bounding_2d.rs b/examples/2d/bounding_2d.rs index d6377bd5614b32..a360dfb6c0bf46 100644 --- a/examples/2d/bounding_2d.rs +++ b/examples/2d/bounding_2d.rs @@ -324,11 +324,7 @@ fn ray_cast_system( **intersects = toi.is_some(); if let Some(toi) = toi { for r in [1., 2., 3.] { - gizmos.circle_2d( - ray_cast.ray.origin + *ray_cast.ray.direction * toi, - r, - GREEN, - ); + gizmos.circle_2d(ray_cast.ray.origin + *ray_cast.ray.direction * toi, r, LIME); } } } @@ -359,7 +355,7 @@ fn aabb_cast_system( + aabb_cast.aabb.center(), 0., aabb_cast.aabb.half_size() * 2., - GREEN, + LIME, ); } } @@ -389,7 +385,7 @@ fn bounding_circle_cast_system( + *circle_cast.ray.ray.direction * toi + circle_cast.circle.center(), circle_cast.circle.radius(), - GREEN, + LIME, ); } } diff --git a/examples/2d/text2d.rs b/examples/2d/text2d.rs index a0229545bd691e..bb7325ac1f895a 100644 --- a/examples/2d/text2d.rs +++ b/examples/2d/text2d.rs @@ -141,7 +141,7 @@ fn setup(mut commands: Commands, asset_server: Res) { for (text_anchor, color) in [ (Anchor::TopLeft, Color::Srgba(RED)), - (Anchor::TopRight, Color::Srgba(GREEN)), + (Anchor::TopRight, Color::Srgba(LIME)), (Anchor::BottomRight, Color::Srgba(BLUE)), (Anchor::BottomLeft, Color::Srgba(YELLOW)), ] { diff --git a/examples/3d/lighting.rs b/examples/3d/lighting.rs index 31e736ca873cc2..59aadd61dbfc8c 100644 --- a/examples/3d/lighting.rs +++ b/examples/3d/lighting.rs @@ -159,7 +159,7 @@ fn setup( .looking_at(Vec3::new(-1.0, 0.0, 0.0), Vec3::Z), spot_light: SpotLight { intensity: 100_000.0, - color: GREEN.into(), + color: LIME.into(), shadows_enabled: true, inner_angle: 0.6, outer_angle: 0.8, @@ -172,7 +172,7 @@ fn setup( transform: Transform::from_rotation(Quat::from_rotation_x(PI / 2.0)), mesh: meshes.add(Capsule3d::new(0.1, 0.125)), material: materials.add(StandardMaterial { - base_color: GREEN.into(), + base_color: LIME.into(), emissive: Color::linear_rgba(0.0, 7.13, 0.0, 0.0), ..default() }), diff --git a/examples/3d/shadow_caster_receiver.rs b/examples/3d/shadow_caster_receiver.rs index 56296301b2eebd..97426737d925f8 100644 --- a/examples/3d/shadow_caster_receiver.rs +++ b/examples/3d/shadow_caster_receiver.rs @@ -3,7 +3,7 @@ use std::f32::consts::PI; use bevy::{ - color::palettes::basic::{BLUE, GREEN, RED}, + color::palettes::basic::{BLUE, LIME, RED}, pbr::{light_consts, CascadeShadowConfigBuilder, NotShadowCaster, NotShadowReceiver}, prelude::*, }; @@ -62,7 +62,7 @@ fn setup( commands.spawn(( PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(20.0, 20.0)), - material: materials.add(Color::from(GREEN)), + material: materials.add(Color::from(LIME)), transform: Transform::from_xyz(0.0, 1.0, -10.0), ..default() }, diff --git a/examples/3d/transmission.rs b/examples/3d/transmission.rs index 8aa1e766884e51..e2cf9481ecb9c3 100644 --- a/examples/3d/transmission.rs +++ b/examples/3d/transmission.rs @@ -213,7 +213,7 @@ fn setup( PbrBundle { mesh: icosphere_mesh.clone(), material: materials.add(StandardMaterial { - base_color: GREEN.into(), + base_color: LIME.into(), specular_transmission: 0.9, diffuse_transmission: 1.0, thickness: 1.8, diff --git a/examples/3d/wireframe.rs b/examples/3d/wireframe.rs index 3d22de808c289a..aaeb42393b3188 100644 --- a/examples/3d/wireframe.rs +++ b/examples/3d/wireframe.rs @@ -82,16 +82,14 @@ fn setup( commands.spawn(( PbrBundle { mesh: meshes.add(Cuboid::default()), - material: materials.add(Color::from(GREEN)), + material: materials.add(Color::from(LIME)), transform: Transform::from_xyz(1.0, 0.5, 1.0), ..default() }, Wireframe, // This lets you configure the wireframe color of this entity. // If not set, this will use the color in `WireframeConfig` - WireframeColor { - color: GREEN.into(), - }, + WireframeColor { color: LIME.into() }, )); // light @@ -157,10 +155,10 @@ Color: {:?} // Toggle the color of a wireframe using WireframeColor and not the global color if keyboard_input.just_pressed(KeyCode::KeyC) { for mut color in &mut wireframe_colors { - color.color = if color.color == GREEN.into() { + color.color = if color.color == LIME.into() { RED.into() } else { - GREEN.into() + LIME.into() }; } } diff --git a/examples/audio/spatial_audio_2d.rs b/examples/audio/spatial_audio_2d.rs index 143ff115823790..c17776b5c2bee8 100644 --- a/examples/audio/spatial_audio_2d.rs +++ b/examples/audio/spatial_audio_2d.rs @@ -65,7 +65,7 @@ fn setup( // right ear parent.spawn(SpriteBundle { sprite: Sprite { - color: GREEN.into(), + color: LIME.into(), custom_size: Some(Vec2::splat(20.0)), ..default() }, diff --git a/examples/audio/spatial_audio_3d.rs b/examples/audio/spatial_audio_3d.rs index 1841f250a4cf1d..87722733d49065 100644 --- a/examples/audio/spatial_audio_3d.rs +++ b/examples/audio/spatial_audio_3d.rs @@ -1,6 +1,6 @@ //! This example illustrates how to load and play an audio file, and control where the sounds seems to come from. use bevy::{ - color::palettes::basic::{BLUE, GREEN, RED}, + color::palettes::basic::{BLUE, LIME, RED}, prelude::*, }; @@ -52,7 +52,7 @@ fn setup( // right ear indicator parent.spawn(PbrBundle { mesh: meshes.add(Cuboid::new(0.2, 0.2, 0.2)), - material: materials.add(Color::from(GREEN)), + material: materials.add(Color::from(LIME)), transform: Transform::from_translation(listener.right_ear_offset), ..default() }); diff --git a/examples/ecs/hierarchy.rs b/examples/ecs/hierarchy.rs index 7faa0bab087f07..b61f21f24ae946 100644 --- a/examples/ecs/hierarchy.rs +++ b/examples/ecs/hierarchy.rs @@ -47,7 +47,7 @@ fn setup(mut commands: Commands, asset_server: Res) { transform: Transform::from_xyz(0.0, 250.0, 0.0).with_scale(Vec3::splat(0.75)), texture, sprite: Sprite { - color: GREEN.into(), + color: LIME.into(), ..default() }, ..default() diff --git a/examples/games/game_menu.rs b/examples/games/game_menu.rs index e23448c3c50db2..b6f1f533de8bc9 100644 --- a/examples/games/game_menu.rs +++ b/examples/games/game_menu.rs @@ -116,7 +116,7 @@ mod splash { mod game { use bevy::{ - color::palettes::basic::{BLUE, GREEN}, + color::palettes::basic::{BLUE, LIME}, prelude::*, }; @@ -211,7 +211,7 @@ mod game { format!("volume: {:?}", *volume), TextStyle { font_size: 60.0, - color: GREEN.into(), + color: LIME.into(), ..default() }, ), diff --git a/examples/gizmos/2d_gizmos.rs b/examples/gizmos/2d_gizmos.rs index aae281286e71e9..a4604ed1b46c8e 100644 --- a/examples/gizmos/2d_gizmos.rs +++ b/examples/gizmos/2d_gizmos.rs @@ -39,7 +39,7 @@ fn draw_example_collection( ) { let sin = time.elapsed_seconds().sin() * 50.; gizmos.line_2d(Vec2::Y * -sin, Vec2::splat(-80.), RED); - gizmos.ray_2d(Vec2::Y * sin, Vec2::splat(80.), GREEN); + gizmos.ray_2d(Vec2::Y * sin, Vec2::splat(80.), LIME); gizmos .grid_2d( @@ -56,7 +56,7 @@ fn draw_example_collection( gizmos.linestrip_gradient_2d([ (Vec2::Y * 300., BLUE), (Vec2::new(-255., -155.), RED), - (Vec2::new(255., -155.), GREEN), + (Vec2::new(255., -155.), LIME), (Vec2::Y * 300., BLUE), ]); diff --git a/examples/gizmos/3d_gizmos.rs b/examples/gizmos/3d_gizmos.rs index adb995f4b816ac..973d3f13815c14 100644 --- a/examples/gizmos/3d_gizmos.rs +++ b/examples/gizmos/3d_gizmos.rs @@ -103,7 +103,7 @@ fn draw_example_collection( Vec3::new(time.elapsed_seconds().cos() * 2.5, 1., 0.), Quat::from_rotation_y(PI / 2.), Vec2::splat(2.), - GREEN, + LIME, ); my_gizmos.sphere(Vec3::new(1., 0.5, 0.), Quat::IDENTITY, 0.5, RED); diff --git a/examples/stress_tests/bevymark.rs b/examples/stress_tests/bevymark.rs index 77327771340d24..f47065e5bd605a 100644 --- a/examples/stress_tests/bevymark.rs +++ b/examples/stress_tests/bevymark.rs @@ -253,13 +253,13 @@ fn setup( .with_children(|c| { c.spawn(( TextBundle::from_sections([ - text_section(GREEN, "Bird Count: "), + text_section(LIME, "Bird Count: "), text_section(AQUA, ""), - text_section(GREEN, "\nFPS (raw): "), + text_section(LIME, "\nFPS (raw): "), text_section(AQUA, ""), - text_section(GREEN, "\nFPS (SMA): "), + text_section(LIME, "\nFPS (SMA): "), text_section(AQUA, ""), - text_section(GREEN, "\nFPS (EMA): "), + text_section(LIME, "\nFPS (EMA): "), text_section(AQUA, ""), ]), StatsText, diff --git a/examples/ui/text_debug.rs b/examples/ui/text_debug.rs index 9ddc0d08bdfb39..c8f06d91c188fc 100644 --- a/examples/ui/text_debug.rs +++ b/examples/ui/text_debug.rs @@ -170,7 +170,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { TextSection::from_style(TextStyle { font: font.clone(), font_size: 25.0, - color: GREEN.into(), + color: LIME.into(), }), TextSection::new( " ms/frame", diff --git a/examples/ui/ui.rs b/examples/ui/ui.rs index a3e4c6d74227bb..3a314237af2a7c 100644 --- a/examples/ui/ui.rs +++ b/examples/ui/ui.rs @@ -5,7 +5,7 @@ use bevy::{ accesskit::{NodeBuilder, Role}, AccessibilityNode, }, - color::palettes::basic::GREEN, + color::palettes::basic::LIME, input::mouse::{MouseScrollUnit, MouseWheel}, prelude::*, winit::WinitSettings, @@ -166,7 +166,7 @@ fn setup(mut commands: Commands, asset_server: Res) { border: UiRect::all(Val::Px(20.)), ..default() }, - border_color: GREEN.into(), + border_color: LIME.into(), background_color: Color::srgb(0.4, 0.4, 1.).into(), ..default() }) diff --git a/examples/ui/viewport_debug.rs b/examples/ui/viewport_debug.rs index 689106e924f98b..2c8a27167085fd 100644 --- a/examples/ui/viewport_debug.rs +++ b/examples/ui/viewport_debug.rs @@ -7,7 +7,7 @@ use bevy::{color::palettes::css::*, prelude::*}; const PALETTE: [Srgba; 10] = [ - RED, YELLOW, WHITE, BEIGE, AQUA, CRIMSON, NAVY, AZURE, GREEN, BLACK, + RED, YELLOW, WHITE, BEIGE, AQUA, CRIMSON, NAVY, AZURE, LIME, BLACK, ]; #[derive(Component, Default, PartialEq)] diff --git a/examples/ui/z_index.rs b/examples/ui/z_index.rs index ac1239ef9265c2..475af2d27c493f 100644 --- a/examples/ui/z_index.rs +++ b/examples/ui/z_index.rs @@ -4,7 +4,7 @@ //! depth of nodes compared to their siblings, but also compared to the entire UI. use bevy::{ - color::palettes::basic::{BLUE, GRAY, GREEN, PURPLE, RED, YELLOW}, + color::palettes::basic::{BLUE, GRAY, LIME, PURPLE, RED, YELLOW}, prelude::*, }; @@ -79,7 +79,7 @@ fn setup(mut commands: Commands) { // it will show under other nodes in the gray container. parent.spawn(NodeBundle { z_index: ZIndex::Local(-1), - background_color: GREEN.into(), + background_color: LIME.into(), style: Style { position_type: PositionType::Absolute, left: Val::Px(70.0), diff --git a/examples/window/low_power.rs b/examples/window/low_power.rs index ace3e2fe5a1bcc..f175167130399f 100644 --- a/examples/window/low_power.rs +++ b/examples/window/low_power.rs @@ -93,7 +93,7 @@ fn update_winit( pub(crate) mod test_setup { use crate::ExampleMode; use bevy::{ - color::palettes::basic::{GREEN, YELLOW}, + color::palettes::basic::{LIME, YELLOW}, prelude::*, window::RequestRedraw, }; @@ -181,7 +181,7 @@ pub(crate) mod test_setup { ), TextSection::from_style(TextStyle { font_size: 50.0, - color: GREEN.into(), + color: LIME.into(), ..default() }), TextSection::new(