From f940f78c880a3f6be92479f82aaac5a2b5587e48 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Sat, 24 Feb 2024 16:35:32 -0500 Subject: [PATCH] Rename `bevy_render::Color` to `LegacyColor` (#12069) # Objective The migration process for `bevy_color` (#12013) will be fairly involved: there will be hundreds of affected files, and a large number of APIs. ## Solution To allow us to proceed granularly, we're going to keep both `bevy_color::Color` (new) and `bevy_render::Color` (old) around until the migration is complete. However, simply doing this directly is confusing! They're both called `Color`, making it very hard to tell when a portion of the code has been ported. As discussed in #12056, by renaming the old `Color` type, we can make it easier to gradually migrate over, one API at a time. ## Migration Guide THIS MIGRATION GUIDE INTENTIONALLY LEFT BLANK. This change should not be shipped to end users: delete this section in the final migration guide! --------- Co-authored-by: Alice Cecile --- crates/bevy_color/src/color.rs | 2 +- crates/bevy_color/src/hsla.rs | 10 +- crates/bevy_color/src/lcha.rs | 10 +- crates/bevy_color/src/lib.rs | 2 +- crates/bevy_color/src/linear_rgba.rs | 10 +- crates/bevy_color/src/oklaba.rs | 2 +- crates/bevy_color/src/srgba.rs | 10 +- crates/bevy_color/src/xyza.rs | 8 +- crates/bevy_core_pipeline/src/bloom/mod.rs | 6 +- crates/bevy_core_pipeline/src/core_3d/mod.rs | 13 +- .../bevy_core_pipeline/src/msaa_writeback.rs | 4 +- crates/bevy_gizmos/src/aabb.rs | 10 +- crates/bevy_gizmos/src/arcs.rs | 26 +- crates/bevy_gizmos/src/arrows.rs | 19 +- crates/bevy_gizmos/src/circles.rs | 30 +- crates/bevy_gizmos/src/gizmos.rs | 97 +-- crates/bevy_gizmos/src/lib.rs | 2 +- crates/bevy_gizmos/src/primitives/dim2.rs | 44 +- crates/bevy_gizmos/src/primitives/dim3.rs | 44 +- crates/bevy_gizmos/src/primitives/helpers.rs | 8 +- crates/bevy_gltf/src/loader.rs | 14 +- crates/bevy_internal/src/lib.rs | 2 +- crates/bevy_pbr/src/fog.rs | 34 +- crates/bevy_pbr/src/lib.rs | 4 +- crates/bevy_pbr/src/light.rs | 20 +- crates/bevy_pbr/src/material.rs | 6 +- crates/bevy_pbr/src/pbr_material.rs | 30 +- crates/bevy_pbr/src/render/light.rs | 6 +- crates/bevy_pbr/src/wireframe.rs | 8 +- crates/bevy_render/src/camera/clear_color.rs | 12 +- crates/bevy_render/src/color/mod.rs | 681 +++++++++--------- crates/bevy_render/src/lib.rs | 4 +- .../src/render_phase/draw_state.rs | 4 +- .../src/render_resource/bind_group.rs | 28 +- .../src/texture/texture_attachment.rs | 6 +- .../bevy_sprite/src/mesh2d/color_material.rs | 13 +- crates/bevy_sprite/src/mesh2d/material.rs | 6 +- crates/bevy_sprite/src/render/mod.rs | 8 +- crates/bevy_sprite/src/sprite.rs | 4 +- crates/bevy_text/src/text.rs | 18 +- crates/bevy_text/src/text2d.rs | 4 +- crates/bevy_ui/src/node_bundles.rs | 12 +- crates/bevy_ui/src/render/mod.rs | 6 +- crates/bevy_ui/src/ui_material.rs | 6 +- crates/bevy_ui/src/ui_node.rs | 38 +- errors/B0004.md | 4 +- examples/2d/2d_shapes.rs | 2 +- examples/2d/2d_viewport_to_world.rs | 2 +- examples/2d/bloom_2d.rs | 8 +- examples/2d/bounding_2d.rs | 20 +- examples/2d/custom_gltf_vertex_attribute.rs | 2 +- examples/2d/mesh2d.rs | 2 +- examples/2d/mesh2d_manual.rs | 4 +- examples/2d/mesh2d_vertex_color_texture.rs | 8 +- examples/2d/pixel_grid_snap.rs | 2 +- examples/2d/sprite_slice.rs | 2 +- examples/2d/text2d.rs | 16 +- examples/2d/texture_atlas.rs | 4 +- examples/2d/transparency_2d.rs | 4 +- examples/3d/3d_scene.rs | 4 +- examples/3d/3d_shapes.rs | 2 +- examples/3d/3d_viewport_to_world.rs | 4 +- examples/3d/animated_material.rs | 4 +- examples/3d/anti_aliasing.rs | 4 +- examples/3d/atmospheric_fog.rs | 12 +- examples/3d/blend_modes.rs | 8 +- examples/3d/bloom_3d.rs | 10 +- examples/3d/deferred_rendering.rs | 14 +- examples/3d/deterministic.rs | 2 +- examples/3d/fog.rs | 8 +- examples/3d/irradiance_volumes.rs | 10 +- examples/3d/lighting.rs | 30 +- examples/3d/lightmaps.rs | 2 +- examples/3d/lines.rs | 8 +- examples/3d/orthographic.rs | 10 +- examples/3d/parallax_mapping.rs | 2 +- examples/3d/parenting.rs | 2 +- examples/3d/pbr.rs | 6 +- examples/3d/reflection_probes.rs | 4 +- examples/3d/render_to_texture.rs | 4 +- examples/3d/shadow_biases.rs | 6 +- examples/3d/shadow_caster_receiver.rs | 10 +- examples/3d/skybox.rs | 2 +- examples/3d/spherical_area_lights.rs | 6 +- examples/3d/split_screen.rs | 6 +- examples/3d/spotlight.rs | 14 +- examples/3d/ssao.rs | 4 +- examples/3d/texture.rs | 4 +- examples/3d/tonemapping.rs | 12 +- examples/3d/transmission.rs | 24 +- examples/3d/transparency_3d.rs | 10 +- examples/3d/two_passes.rs | 4 +- examples/3d/vertex_colors.rs | 4 +- examples/3d/wireframe.rs | 24 +- examples/animation/animated_fox.rs | 4 +- examples/animation/animated_transform.rs | 6 +- examples/animation/cubic_curve.rs | 6 +- examples/animation/custom_skinned_mesh.rs | 2 +- examples/asset/asset_loading.rs | 2 +- examples/async_tasks/async_compute.rs | 2 +- .../external_source_external_thread.rs | 2 +- examples/audio/spatial_audio_2d.rs | 6 +- examples/audio/spatial_audio_3d.rs | 6 +- examples/ecs/hierarchy.rs | 4 +- examples/ecs/iter_combinations.rs | 10 +- examples/ecs/state.rs | 8 +- examples/games/alien_cake_addict.rs | 6 +- examples/games/breakout.rs | 14 +- examples/games/contributors.rs | 11 +- examples/games/game_menu.rs | 28 +- examples/games/stepping.rs | 4 +- examples/gizmos/2d_gizmos.rs | 32 +- examples/gizmos/3d_gizmos.rs | 27 +- examples/math/render_primitives.rs | 10 +- examples/mobile/src/lib.rs | 14 +- .../shader/compute_shader_game_of_life.rs | 2 +- examples/shader/custom_vertex_attribute.rs | 4 +- examples/shader/extended_material.rs | 2 +- examples/shader/post_processing.rs | 4 +- examples/shader/shader_defs.rs | 6 +- examples/shader/shader_instancing.rs | 2 +- examples/shader/shader_material.rs | 4 +- examples/shader/shader_material_2d.rs | 4 +- examples/shader/shader_material_glsl.rs | 4 +- .../shader_material_screenspace_texture.rs | 2 +- examples/shader/shader_prepass.rs | 10 +- examples/stress_tests/bevymark.rs | 32 +- examples/stress_tests/many_buttons.rs | 12 +- examples/stress_tests/many_cubes.rs | 4 +- examples/stress_tests/many_foxes.rs | 2 +- examples/stress_tests/many_gizmos.rs | 6 +- examples/stress_tests/many_glyphs.rs | 2 +- examples/stress_tests/many_lights.rs | 6 +- examples/stress_tests/many_sprites.rs | 4 +- examples/stress_tests/text_pipeline.rs | 4 +- examples/time/virtual_time.rs | 4 +- examples/tools/gamepad_viewer.rs | 8 +- examples/transforms/3d_rotation.rs | 2 +- examples/transforms/scale.rs | 2 +- examples/transforms/transform.rs | 4 +- examples/transforms/translation.rs | 2 +- examples/ui/borders.rs | 10 +- examples/ui/button.rs | 16 +- examples/ui/display_and_visibility.rs | 33 +- examples/ui/flex_layout.rs | 12 +- examples/ui/font_atlas_debug.rs | 6 +- examples/ui/grid.rs | 48 +- examples/ui/overflow.rs | 16 +- examples/ui/overflow_debug.rs | 2 +- examples/ui/relative_cursor_position.rs | 8 +- examples/ui/render_ui_to_texture.rs | 4 +- examples/ui/size_constraints.rs | 32 +- examples/ui/text.rs | 6 +- examples/ui/text_debug.rs | 20 +- examples/ui/text_wrap_debug.rs | 6 +- examples/ui/transparency_ui.rs | 10 +- examples/ui/ui.rs | 26 +- examples/ui/ui_material.rs | 4 +- examples/ui/ui_scaling.rs | 8 +- examples/ui/ui_texture_atlas.rs | 2 +- examples/ui/ui_texture_slice.rs | 2 +- examples/ui/viewport_debug.rs | 22 +- examples/ui/window_fallthrough.rs | 2 +- examples/ui/z_index.rs | 14 +- examples/window/clear_color.rs | 4 +- examples/window/low_power.rs | 8 +- examples/window/scale_factor_override.rs | 2 +- examples/window/screenshot.rs | 4 +- examples/window/transparent_window.rs | 2 +- tests/window/minimising.rs | 6 +- tests/window/resizing.rs | 6 +- 171 files changed, 1209 insertions(+), 1165 deletions(-) diff --git a/crates/bevy_color/src/color.rs b/crates/bevy_color/src/color.rs index df997b44a9a136..106ccfa6ff120c 100644 --- a/crates/bevy_color/src/color.rs +++ b/crates/bevy_color/src/color.rs @@ -1,6 +1,6 @@ use crate::{Alpha, Hsla, Lcha, LinearRgba, Oklaba, Srgba, StandardColor, Xyza}; use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize}; -use bevy_render::color::Color as LegacyColor; +use bevy_render::color::LegacyColor; use serde::{Deserialize, Serialize}; /// An enumerated type that can represent any of the color types in this crate. diff --git a/crates/bevy_color/src/hsla.rs b/crates/bevy_color/src/hsla.rs index 465000bebab3b2..07e350b6b415a2 100644 --- a/crates/bevy_color/src/hsla.rs +++ b/crates/bevy_color/src/hsla.rs @@ -136,9 +136,9 @@ impl From for Hsla { } } -impl From for bevy_render::color::Color { +impl From for bevy_render::color::LegacyColor { fn from(value: Hsla) -> Self { - bevy_render::color::Color::Hsla { + bevy_render::color::LegacyColor::Hsla { hue: value.hue, saturation: value.saturation, lightness: value.lightness, @@ -147,10 +147,10 @@ impl From for bevy_render::color::Color { } } -impl From for Hsla { - fn from(value: bevy_render::color::Color) -> Self { +impl From for Hsla { + fn from(value: bevy_render::color::LegacyColor) -> Self { match value.as_hsla() { - bevy_render::color::Color::Hsla { + bevy_render::color::LegacyColor::Hsla { hue, saturation, lightness, diff --git a/crates/bevy_color/src/lcha.rs b/crates/bevy_color/src/lcha.rs index 885fb1280053cd..c2ed3d1018b612 100644 --- a/crates/bevy_color/src/lcha.rs +++ b/crates/bevy_color/src/lcha.rs @@ -157,9 +157,9 @@ impl From for LinearRgba { } } -impl From for bevy_render::color::Color { +impl From for bevy_render::color::LegacyColor { fn from(value: Lcha) -> Self { - bevy_render::color::Color::Lcha { + bevy_render::color::LegacyColor::Lcha { hue: value.hue, chroma: value.chroma, lightness: value.lightness, @@ -168,10 +168,10 @@ impl From for bevy_render::color::Color { } } -impl From for Lcha { - fn from(value: bevy_render::color::Color) -> Self { +impl From for Lcha { + fn from(value: bevy_render::color::LegacyColor) -> Self { match value.as_lcha() { - bevy_render::color::Color::Lcha { + bevy_render::color::LegacyColor::Lcha { hue, chroma, lightness, diff --git a/crates/bevy_color/src/lib.rs b/crates/bevy_color/src/lib.rs index 3030440c7d5edc..acce271335d362 100644 --- a/crates/bevy_color/src/lib.rs +++ b/crates/bevy_color/src/lib.rs @@ -95,7 +95,7 @@ pub use oklaba::*; pub use srgba::*; pub use xyza::*; -use bevy_render::color::Color as LegacyColor; +use bevy_render::color::LegacyColor; /// Describes the traits that a color should implement for consistency. pub(crate) trait StandardColor diff --git a/crates/bevy_color/src/linear_rgba.rs b/crates/bevy_color/src/linear_rgba.rs index d61c0d16791a8a..347e6b295d808c 100644 --- a/crates/bevy_color/src/linear_rgba.rs +++ b/crates/bevy_color/src/linear_rgba.rs @@ -172,9 +172,9 @@ impl From for LinearRgba { } } -impl From for bevy_render::color::Color { +impl From for bevy_render::color::LegacyColor { fn from(value: LinearRgba) -> Self { - bevy_render::color::Color::RgbaLinear { + bevy_render::color::LegacyColor::RgbaLinear { red: value.red, green: value.green, blue: value.blue, @@ -183,10 +183,10 @@ impl From for bevy_render::color::Color { } } -impl From for LinearRgba { - fn from(value: bevy_render::color::Color) -> Self { +impl From for LinearRgba { + fn from(value: bevy_render::color::LegacyColor) -> Self { match value.as_rgba_linear() { - bevy_render::color::Color::RgbaLinear { + bevy_render::color::LegacyColor::RgbaLinear { red, green, blue, diff --git a/crates/bevy_color/src/oklaba.rs b/crates/bevy_color/src/oklaba.rs index 35cb3683d0ccff..f109d7529c7a70 100644 --- a/crates/bevy_color/src/oklaba.rs +++ b/crates/bevy_color/src/oklaba.rs @@ -3,7 +3,7 @@ use crate::{ StandardColor, }; use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize}; -use bevy_render::color::Color as LegacyColor; +use bevy_render::color::LegacyColor; use serde::{Deserialize, Serialize}; /// Color in Oklaba color space, with alpha diff --git a/crates/bevy_color/src/srgba.rs b/crates/bevy_color/src/srgba.rs index f75d1cf99f5b6c..b1d17a138016b4 100644 --- a/crates/bevy_color/src/srgba.rs +++ b/crates/bevy_color/src/srgba.rs @@ -267,9 +267,9 @@ impl From for Srgba { } } -impl From for bevy_render::color::Color { +impl From for bevy_render::color::LegacyColor { fn from(value: Srgba) -> Self { - bevy_render::color::Color::Rgba { + bevy_render::color::LegacyColor::Rgba { red: value.red, green: value.green, blue: value.blue, @@ -278,10 +278,10 @@ impl From for bevy_render::color::Color { } } -impl From for Srgba { - fn from(value: bevy_render::color::Color) -> Self { +impl From for Srgba { + fn from(value: bevy_render::color::LegacyColor) -> Self { match value.as_rgba() { - bevy_render::color::Color::Rgba { + bevy_render::color::LegacyColor::Rgba { red, green, blue, diff --git a/crates/bevy_color/src/xyza.rs b/crates/bevy_color/src/xyza.rs index b8457724f64a16..9445e1705e4518 100644 --- a/crates/bevy_color/src/xyza.rs +++ b/crates/bevy_color/src/xyza.rs @@ -1,6 +1,6 @@ use crate::{Alpha, Hsla, Lcha, LinearRgba, Luminance, Mix, Oklaba, Srgba, StandardColor}; use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize}; -use bevy_render::color::Color; +use bevy_render::color::LegacyColor; use serde::{Deserialize, Serialize}; /// [CIE 1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space, also known as XYZ, with an alpha channel. @@ -208,13 +208,13 @@ impl From for Oklaba { } } -impl From for Xyza { - fn from(value: Color) -> Self { +impl From for Xyza { + fn from(value: LegacyColor) -> Self { LinearRgba::from(value).into() } } -impl From for Color { +impl From for LegacyColor { fn from(value: Xyza) -> Self { LinearRgba::from(value).into() } diff --git a/crates/bevy_core_pipeline/src/bloom/mod.rs b/crates/bevy_core_pipeline/src/bloom/mod.rs index 953f4218729c35..c76ea78934ce23 100644 --- a/crates/bevy_core_pipeline/src/bloom/mod.rs +++ b/crates/bevy_core_pipeline/src/bloom/mod.rs @@ -17,7 +17,7 @@ use bevy_render::{ extract_component::{ ComponentUniforms, DynamicUniformIndex, ExtractComponentPlugin, UniformComponentPlugin, }, - prelude::Color, + prelude::LegacyColor, render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, render_resource::*, renderer::{RenderContext, RenderDevice}, @@ -240,7 +240,7 @@ impl ViewNode for BloomNode { mip as f32, (bloom_texture.mip_count - 1) as f32, ); - upsampling_pass.set_blend_constant(Color::rgb_linear(blend, blend, blend)); + upsampling_pass.set_blend_constant(LegacyColor::rgb_linear(blend, blend, blend)); upsampling_pass.draw(0..3, 0..1); } @@ -267,7 +267,7 @@ impl ViewNode for BloomNode { } let blend = compute_blend_factor(bloom_settings, 0.0, (bloom_texture.mip_count - 1) as f32); - upsampling_final_pass.set_blend_constant(Color::rgb_linear(blend, blend, blend)); + upsampling_final_pass.set_blend_constant(LegacyColor::rgb_linear(blend, blend, blend)); upsampling_final_pass.draw(0..3, 0..1); } diff --git a/crates/bevy_core_pipeline/src/core_3d/mod.rs b/crates/bevy_core_pipeline/src/core_3d/mod.rs index b8312875a0905e..9c049683ebe9e3 100644 --- a/crates/bevy_core_pipeline/src/core_3d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_3d/mod.rs @@ -49,7 +49,7 @@ use bevy_app::{App, Plugin, PostUpdate}; use bevy_ecs::prelude::*; use bevy_render::{ camera::{Camera, ExtractedCamera}, - color::Color, + color::LegacyColor, extract_component::ExtractComponentPlugin, mesh::Mesh, prelude::Msaa, @@ -836,18 +836,19 @@ pub fn prepare_prepass_textures( }); commands.entity(entity).insert(ViewPrepassTextures { - depth: cached_depth_texture.map(|t| ColorAttachment::new(t, None, Some(Color::BLACK))), + depth: cached_depth_texture + .map(|t| ColorAttachment::new(t, None, Some(LegacyColor::BLACK))), normal: cached_normals_texture - .map(|t| ColorAttachment::new(t, None, Some(Color::BLACK))), + .map(|t| ColorAttachment::new(t, None, Some(LegacyColor::BLACK))), // Red and Green channels are X and Y components of the motion vectors // Blue channel doesn't matter, but set to 0.0 for possible faster clear // https://gpuopen.com/performance/#clears motion_vectors: cached_motion_vectors_texture - .map(|t| ColorAttachment::new(t, None, Some(Color::BLACK))), + .map(|t| ColorAttachment::new(t, None, Some(LegacyColor::BLACK))), deferred: cached_deferred_texture - .map(|t| ColorAttachment::new(t, None, Some(Color::BLACK))), + .map(|t| ColorAttachment::new(t, None, Some(LegacyColor::BLACK))), deferred_lighting_pass_id: cached_deferred_lighting_pass_id_texture - .map(|t| ColorAttachment::new(t, None, Some(Color::BLACK))), + .map(|t| ColorAttachment::new(t, None, Some(LegacyColor::BLACK))), size, }); } diff --git a/crates/bevy_core_pipeline/src/msaa_writeback.rs b/crates/bevy_core_pipeline/src/msaa_writeback.rs index f164e3297390c5..1cf6b02f396299 100644 --- a/crates/bevy_core_pipeline/src/msaa_writeback.rs +++ b/crates/bevy_core_pipeline/src/msaa_writeback.rs @@ -7,7 +7,7 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; use bevy_render::{ camera::ExtractedCamera, - color::Color, + color::LegacyColor, render_graph::{Node, NodeRunError, RenderGraphApp, RenderGraphContext}, render_resource::BindGroupEntries, renderer::RenderContext, @@ -93,7 +93,7 @@ impl Node for MsaaWritebackNode { view: target.sampled_main_texture_view().unwrap(), resolve_target: Some(post_process.destination), ops: Operations { - load: LoadOp::Clear(Color::BLACK.into()), + load: LoadOp::Clear(LegacyColor::BLACK.into()), store: StoreOp::Store, }, })], diff --git a/crates/bevy_gizmos/src/aabb.rs b/crates/bevy_gizmos/src/aabb.rs index ed9eccae027b4b..65b726bea99943 100644 --- a/crates/bevy_gizmos/src/aabb.rs +++ b/crates/bevy_gizmos/src/aabb.rs @@ -12,7 +12,7 @@ use bevy_ecs::{ system::{Query, Res}, }; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; -use bevy_render::{color::Color, primitives::Aabb}; +use bevy_render::{color::LegacyColor, primitives::Aabb}; use bevy_transform::{ components::{GlobalTransform, Transform}, TransformSystem, @@ -57,7 +57,7 @@ pub struct AabbGizmoConfigGroup { /// A random color is chosen per box if `None`. /// /// Defaults to `None`. - pub default_color: Option, + pub default_color: Option, } /// Add this [`Component`] to an entity to draw its [`Aabb`] component. @@ -67,7 +67,7 @@ pub struct ShowAabbGizmo { /// The color of the box. /// /// The default color from the [`AabbGizmoConfigGroup`] config is used if `None`, - pub color: Option, + pub color: Option, } fn draw_aabbs( @@ -96,7 +96,7 @@ fn draw_all_aabbs( } } -fn color_from_entity(entity: Entity) -> Color { +fn color_from_entity(entity: Entity) -> LegacyColor { let index = entity.index(); // from https://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/ @@ -108,7 +108,7 @@ fn color_from_entity(entity: Entity) -> Color { const RATIO_360: f32 = 360.0 / u32::MAX as f32; let hue = index.wrapping_mul(FRAC_U32MAX_GOLDEN_RATIO) as f32 * RATIO_360; - Color::hsl(hue, 1., 0.5) + LegacyColor::hsl(hue, 1., 0.5) } fn aabb_transform(aabb: Aabb, transform: GlobalTransform) -> GlobalTransform { diff --git a/crates/bevy_gizmos/src/arcs.rs b/crates/bevy_gizmos/src/arcs.rs index 26f95c03465a9d..09864b60057b42 100644 --- a/crates/bevy_gizmos/src/arcs.rs +++ b/crates/bevy_gizmos/src/arcs.rs @@ -6,7 +6,7 @@ use crate::circles::DEFAULT_CIRCLE_SEGMENTS; use crate::prelude::{GizmoConfigGroup, Gizmos}; use bevy_math::{Quat, Vec2, Vec3}; -use bevy_render::color::Color; +use bevy_render::color::LegacyColor; use std::f32::consts::TAU; // === 2D === @@ -30,12 +30,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_math::prelude::*; /// # use std::f32::consts::PI; /// fn system(mut gizmos: Gizmos) { - /// gizmos.arc_2d(Vec2::ZERO, 0., PI / 4., 1., Color::GREEN); + /// gizmos.arc_2d(Vec2::ZERO, 0., PI / 4., 1., LegacyColor::GREEN); /// /// // Arcs have 32 line-segments by default. /// // You may want to increase this for larger arcs. /// gizmos - /// .arc_2d(Vec2::ZERO, 0., PI / 4., 5., Color::RED) + /// .arc_2d(Vec2::ZERO, 0., PI / 4., 5., LegacyColor::RED) /// .segments(64); /// } /// # bevy_ecs::system::assert_is_system(system); @@ -47,7 +47,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { direction_angle: f32, arc_angle: f32, radius: f32, - color: Color, + color: LegacyColor, ) -> Arc2dBuilder<'_, 'w, 's, T> { Arc2dBuilder { gizmos: self, @@ -68,7 +68,7 @@ pub struct Arc2dBuilder<'a, 'w, 's, T: GizmoConfigGroup> { direction_angle: f32, arc_angle: f32, radius: f32, - color: Color, + color: LegacyColor, segments: Option, } @@ -152,7 +152,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// 0.25, /// Vec3::ONE, /// rotation, - /// Color::ORANGE + /// LegacyColor::ORANGE /// ) /// .segments(100); /// } @@ -165,7 +165,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { radius: f32, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Arc3dBuilder<'_, 'w, 's, T> { Arc3dBuilder { gizmos: self, @@ -202,7 +202,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// Vec3::ONE, /// Vec3::ONE + Vec3::NEG_ONE, /// Vec3::ZERO, - /// Color::ORANGE + /// LegacyColor::ORANGE /// ) /// .segments(100); /// } @@ -221,7 +221,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { center: Vec3, from: Vec3, to: Vec3, - color: Color, + color: LegacyColor, ) -> Arc3dBuilder<'_, 'w, 's, T> { self.arc_from_to(center, from, to, color, |x| x) } @@ -248,7 +248,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// Vec3::ONE, /// Vec3::ONE + Vec3::NEG_ONE, /// Vec3::ZERO, - /// Color::ORANGE + /// LegacyColor::ORANGE /// ) /// .segments(100); /// } @@ -267,7 +267,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { center: Vec3, from: Vec3, to: Vec3, - color: Color, + color: LegacyColor, ) -> Arc3dBuilder<'_, 'w, 's, T> { self.arc_from_to(center, from, to, color, |angle| { if angle > 0.0 { @@ -286,7 +286,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { center: Vec3, from: Vec3, to: Vec3, - color: Color, + color: LegacyColor, angle_fn: impl Fn(f32) -> f32, ) -> Arc3dBuilder<'_, 'w, 's, T> { // `from` and `to` can be the same here since in either case nothing gets rendered and the @@ -331,7 +331,7 @@ pub struct Arc3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> { rotation: Quat, angle: f32, radius: f32, - color: Color, + color: LegacyColor, segments: Option, } diff --git a/crates/bevy_gizmos/src/arrows.rs b/crates/bevy_gizmos/src/arrows.rs index 541fc6edab79bf..9dc81b77599c52 100644 --- a/crates/bevy_gizmos/src/arrows.rs +++ b/crates/bevy_gizmos/src/arrows.rs @@ -5,14 +5,14 @@ use crate::prelude::{GizmoConfigGroup, Gizmos}; use bevy_math::{Quat, Vec2, Vec3}; -use bevy_render::color::Color; +use bevy_render::color::LegacyColor; /// A builder returned by [`Gizmos::arrow`] and [`Gizmos::arrow_2d`] pub struct ArrowBuilder<'a, 'w, 's, T: GizmoConfigGroup> { gizmos: &'a mut Gizmos<'w, 's, T>, start: Vec3, end: Vec3, - color: Color, + color: LegacyColor, tip_length: f32, } @@ -26,7 +26,7 @@ impl ArrowBuilder<'_, '_, '_, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.arrow(Vec3::ZERO, Vec3::ONE, Color::GREEN) + /// gizmos.arrow(Vec3::ZERO, Vec3::ONE, LegacyColor::GREEN) /// .with_tip_length(3.); /// } /// # bevy_ecs::system::assert_is_system(system); @@ -77,11 +77,16 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.arrow(Vec3::ZERO, Vec3::ONE, Color::GREEN); + /// gizmos.arrow(Vec3::ZERO, Vec3::ONE, LegacyColor::GREEN); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` - pub fn arrow(&mut self, start: Vec3, end: Vec3, color: Color) -> ArrowBuilder<'_, 'w, 's, T> { + pub fn arrow( + &mut self, + start: Vec3, + end: Vec3, + color: LegacyColor, + ) -> ArrowBuilder<'_, 'w, 's, T> { let length = (end - start).length(); ArrowBuilder { gizmos: self, @@ -102,7 +107,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.arrow_2d(Vec2::ZERO, Vec2::X, Color::GREEN); + /// gizmos.arrow_2d(Vec2::ZERO, Vec2::X, LegacyColor::GREEN); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` @@ -110,7 +115,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { &mut self, start: Vec2, end: Vec2, - color: Color, + color: LegacyColor, ) -> ArrowBuilder<'_, 'w, 's, T> { self.arrow(start.extend(0.), end.extend(0.), color) } diff --git a/crates/bevy_gizmos/src/circles.rs b/crates/bevy_gizmos/src/circles.rs index f8b48753b46a15..380f8182378f53 100644 --- a/crates/bevy_gizmos/src/circles.rs +++ b/crates/bevy_gizmos/src/circles.rs @@ -6,7 +6,7 @@ use crate::prelude::{GizmoConfigGroup, Gizmos}; use bevy_math::Mat2; use bevy_math::{primitives::Direction3d, Quat, Vec2, Vec3}; -use bevy_render::color::Color; +use bevy_render::color::LegacyColor; use std::f32::consts::TAU; pub(crate) const DEFAULT_CIRCLE_SEGMENTS: usize = 32; @@ -30,12 +30,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.ellipse(Vec3::ZERO, Quat::IDENTITY, Vec2::new(1., 2.), Color::GREEN); + /// gizmos.ellipse(Vec3::ZERO, Quat::IDENTITY, Vec2::new(1., 2.), LegacyColor::GREEN); /// /// // Ellipses have 32 line-segments by default. /// // You may want to increase this for larger ellipses. /// gizmos - /// .ellipse(Vec3::ZERO, Quat::IDENTITY, Vec2::new(5., 1.), Color::RED) + /// .ellipse(Vec3::ZERO, Quat::IDENTITY, Vec2::new(5., 1.), LegacyColor::RED) /// .segments(64); /// } /// # bevy_ecs::system::assert_is_system(system); @@ -46,7 +46,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { position: Vec3, rotation: Quat, half_size: Vec2, - color: Color, + color: LegacyColor, ) -> EllipseBuilder<'_, 'w, 's, T> { EllipseBuilder { gizmos: self, @@ -68,12 +68,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.ellipse_2d(Vec2::ZERO, 180.0_f32.to_radians(), Vec2::new(2., 1.), Color::GREEN); + /// gizmos.ellipse_2d(Vec2::ZERO, 180.0_f32.to_radians(), Vec2::new(2., 1.), LegacyColor::GREEN); /// /// // Ellipses have 32 line-segments by default. /// // You may want to increase this for larger ellipses. /// gizmos - /// .ellipse_2d(Vec2::ZERO, 180.0_f32.to_radians(), Vec2::new(5., 1.), Color::RED) + /// .ellipse_2d(Vec2::ZERO, 180.0_f32.to_radians(), Vec2::new(5., 1.), LegacyColor::RED) /// .segments(64); /// } /// # bevy_ecs::system::assert_is_system(system); @@ -84,7 +84,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { position: Vec2, angle: f32, half_size: Vec2, - color: Color, + color: LegacyColor, ) -> Ellipse2dBuilder<'_, 'w, 's, T> { Ellipse2dBuilder { gizmos: self, @@ -106,12 +106,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.circle(Vec3::ZERO, Direction3d::Z, 1., Color::GREEN); + /// gizmos.circle(Vec3::ZERO, Direction3d::Z, 1., LegacyColor::GREEN); /// /// // Circles have 32 line-segments by default. /// // You may want to increase this for larger circles. /// gizmos - /// .circle(Vec3::ZERO, Direction3d::Z, 5., Color::RED) + /// .circle(Vec3::ZERO, Direction3d::Z, 5., LegacyColor::RED) /// .segments(64); /// } /// # bevy_ecs::system::assert_is_system(system); @@ -122,7 +122,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { position: Vec3, normal: Direction3d, radius: f32, - color: Color, + color: LegacyColor, ) -> EllipseBuilder<'_, 'w, 's, T> { EllipseBuilder { gizmos: self, @@ -144,12 +144,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.circle_2d(Vec2::ZERO, 1., Color::GREEN); + /// gizmos.circle_2d(Vec2::ZERO, 1., LegacyColor::GREEN); /// /// // Circles have 32 line-segments by default. /// // You may want to increase this for larger circles. /// gizmos - /// .circle_2d(Vec2::ZERO, 5., Color::RED) + /// .circle_2d(Vec2::ZERO, 5., LegacyColor::RED) /// .segments(64); /// } /// # bevy_ecs::system::assert_is_system(system); @@ -159,7 +159,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { &mut self, position: Vec2, radius: f32, - color: Color, + color: LegacyColor, ) -> Ellipse2dBuilder<'_, 'w, 's, T> { Ellipse2dBuilder { gizmos: self, @@ -178,7 +178,7 @@ pub struct EllipseBuilder<'a, 'w, 's, T: GizmoConfigGroup> { position: Vec3, rotation: Quat, half_size: Vec2, - color: Color, + color: LegacyColor, segments: usize, } @@ -209,7 +209,7 @@ pub struct Ellipse2dBuilder<'a, 'w, 's, T: GizmoConfigGroup> { position: Vec2, rotation: Mat2, half_size: Vec2, - color: Color, + color: LegacyColor, segments: usize, } diff --git a/crates/bevy_gizmos/src/gizmos.rs b/crates/bevy_gizmos/src/gizmos.rs index 729d53b40fe12d..33c7981c285d05 100644 --- a/crates/bevy_gizmos/src/gizmos.rs +++ b/crates/bevy_gizmos/src/gizmos.rs @@ -9,7 +9,7 @@ use bevy_ecs::{ world::{unsafe_world_cell::UnsafeWorldCell, World}, }; use bevy_math::{primitives::Direction3d, Mat2, Quat, Vec2, Vec3}; -use bevy_render::color::Color; +use bevy_render::color::LegacyColor; use bevy_transform::TransformPoint; use crate::{ @@ -131,12 +131,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.line(Vec3::ZERO, Vec3::X, Color::GREEN); + /// gizmos.line(Vec3::ZERO, Vec3::X, LegacyColor::GREEN); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` #[inline] - pub fn line(&mut self, start: Vec3, end: Vec3, color: Color) { + pub fn line(&mut self, start: Vec3, end: Vec3, color: LegacyColor) { if !self.enabled { return; } @@ -154,12 +154,18 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.line_gradient(Vec3::ZERO, Vec3::X, Color::GREEN, Color::RED); + /// gizmos.line_gradient(Vec3::ZERO, Vec3::X, LegacyColor::GREEN, LegacyColor::RED); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` #[inline] - pub fn line_gradient(&mut self, start: Vec3, end: Vec3, start_color: Color, end_color: Color) { + pub fn line_gradient( + &mut self, + start: Vec3, + end: Vec3, + start_color: LegacyColor, + end_color: LegacyColor, + ) { if !self.enabled { return; } @@ -177,12 +183,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.ray(Vec3::Y, Vec3::X, Color::GREEN); + /// gizmos.ray(Vec3::Y, Vec3::X, LegacyColor::GREEN); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` #[inline] - pub fn ray(&mut self, start: Vec3, vector: Vec3, color: Color) { + pub fn ray(&mut self, start: Vec3, vector: Vec3, color: LegacyColor) { if !self.enabled { return; } @@ -199,7 +205,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.ray_gradient(Vec3::Y, Vec3::X, Color::GREEN, Color::RED); + /// gizmos.ray_gradient(Vec3::Y, Vec3::X, LegacyColor::GREEN, LegacyColor::RED); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` @@ -208,8 +214,8 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { &mut self, start: Vec3, vector: Vec3, - start_color: Color, - end_color: Color, + start_color: LegacyColor, + end_color: LegacyColor, ) { if !self.enabled { return; @@ -227,12 +233,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.linestrip([Vec3::ZERO, Vec3::X, Vec3::Y], Color::GREEN); + /// gizmos.linestrip([Vec3::ZERO, Vec3::X, Vec3::Y], LegacyColor::GREEN); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` #[inline] - pub fn linestrip(&mut self, positions: impl IntoIterator, color: Color) { + pub fn linestrip(&mut self, positions: impl IntoIterator, color: LegacyColor) { if !self.enabled { return; } @@ -255,15 +261,15 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { /// gizmos.linestrip_gradient([ - /// (Vec3::ZERO, Color::GREEN), - /// (Vec3::X, Color::RED), - /// (Vec3::Y, Color::BLUE) + /// (Vec3::ZERO, LegacyColor::GREEN), + /// (Vec3::X, LegacyColor::RED), + /// (Vec3::Y, LegacyColor::BLUE) /// ]); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` #[inline] - pub fn linestrip_gradient(&mut self, points: impl IntoIterator) { + pub fn linestrip_gradient(&mut self, points: impl IntoIterator) { if !self.enabled { return; } @@ -298,12 +304,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.sphere(Vec3::ZERO, Quat::IDENTITY, 1., Color::BLACK); + /// gizmos.sphere(Vec3::ZERO, Quat::IDENTITY, 1., LegacyColor::BLACK); /// /// // Each circle has 32 line-segments by default. /// // You may want to increase this for larger spheres. /// gizmos - /// .sphere(Vec3::ZERO, Quat::IDENTITY, 5., Color::BLACK) + /// .sphere(Vec3::ZERO, Quat::IDENTITY, 5., LegacyColor::BLACK) /// .circle_segments(64); /// } /// # bevy_ecs::system::assert_is_system(system); @@ -314,7 +320,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { position: Vec3, rotation: Quat, radius: f32, - color: Color, + color: LegacyColor, ) -> SphereBuilder<'_, 'w, 's, T> { SphereBuilder { gizmos: self, @@ -336,12 +342,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.rect(Vec3::ZERO, Quat::IDENTITY, Vec2::ONE, Color::GREEN); + /// gizmos.rect(Vec3::ZERO, Quat::IDENTITY, Vec2::ONE, LegacyColor::GREEN); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` #[inline] - pub fn rect(&mut self, position: Vec3, rotation: Quat, size: Vec2, color: Color) { + pub fn rect(&mut self, position: Vec3, rotation: Quat, size: Vec2, color: LegacyColor) { if !self.enabled { return; } @@ -359,12 +365,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_transform::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.cuboid(Transform::IDENTITY, Color::GREEN); + /// gizmos.cuboid(Transform::IDENTITY, LegacyColor::GREEN); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` #[inline] - pub fn cuboid(&mut self, transform: impl TransformPoint, color: Color) { + pub fn cuboid(&mut self, transform: impl TransformPoint, color: LegacyColor) { if !self.enabled { return; } @@ -397,12 +403,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.line_2d(Vec2::ZERO, Vec2::X, Color::GREEN); + /// gizmos.line_2d(Vec2::ZERO, Vec2::X, LegacyColor::GREEN); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` #[inline] - pub fn line_2d(&mut self, start: Vec2, end: Vec2, color: Color) { + pub fn line_2d(&mut self, start: Vec2, end: Vec2, color: LegacyColor) { if !self.enabled { return; } @@ -419,7 +425,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.line_gradient_2d(Vec2::ZERO, Vec2::X, Color::GREEN, Color::RED); + /// gizmos.line_gradient_2d(Vec2::ZERO, Vec2::X, LegacyColor::GREEN, LegacyColor::RED); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` @@ -428,8 +434,8 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { &mut self, start: Vec2, end: Vec2, - start_color: Color, - end_color: Color, + start_color: LegacyColor, + end_color: LegacyColor, ) { if !self.enabled { return; @@ -447,12 +453,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.linestrip_2d([Vec2::ZERO, Vec2::X, Vec2::Y], Color::GREEN); + /// gizmos.linestrip_2d([Vec2::ZERO, Vec2::X, Vec2::Y], LegacyColor::GREEN); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` #[inline] - pub fn linestrip_2d(&mut self, positions: impl IntoIterator, color: Color) { + pub fn linestrip_2d(&mut self, positions: impl IntoIterator, color: LegacyColor) { if !self.enabled { return; } @@ -470,15 +476,18 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { /// gizmos.linestrip_gradient_2d([ - /// (Vec2::ZERO, Color::GREEN), - /// (Vec2::X, Color::RED), - /// (Vec2::Y, Color::BLUE) + /// (Vec2::ZERO, LegacyColor::GREEN), + /// (Vec2::X, LegacyColor::RED), + /// (Vec2::Y, LegacyColor::BLUE) /// ]); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` #[inline] - pub fn linestrip_gradient_2d(&mut self, positions: impl IntoIterator) { + pub fn linestrip_gradient_2d( + &mut self, + positions: impl IntoIterator, + ) { if !self.enabled { return; } @@ -499,12 +508,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.ray_2d(Vec2::Y, Vec2::X, Color::GREEN); + /// gizmos.ray_2d(Vec2::Y, Vec2::X, LegacyColor::GREEN); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` #[inline] - pub fn ray_2d(&mut self, start: Vec2, vector: Vec2, color: Color) { + pub fn ray_2d(&mut self, start: Vec2, vector: Vec2, color: LegacyColor) { if !self.enabled { return; } @@ -521,7 +530,7 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.line_gradient(Vec3::Y, Vec3::X, Color::GREEN, Color::RED); + /// gizmos.line_gradient(Vec3::Y, Vec3::X, LegacyColor::GREEN, LegacyColor::RED); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` @@ -530,8 +539,8 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { &mut self, start: Vec2, vector: Vec2, - start_color: Color, - end_color: Color, + start_color: LegacyColor, + end_color: LegacyColor, ) { if !self.enabled { return; @@ -549,12 +558,12 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { /// # use bevy_render::prelude::*; /// # use bevy_math::prelude::*; /// fn system(mut gizmos: Gizmos) { - /// gizmos.rect_2d(Vec2::ZERO, 0., Vec2::ONE, Color::GREEN); + /// gizmos.rect_2d(Vec2::ZERO, 0., Vec2::ONE, LegacyColor::GREEN); /// } /// # bevy_ecs::system::assert_is_system(system); /// ``` #[inline] - pub fn rect_2d(&mut self, position: Vec2, rotation: f32, size: Vec2, color: Color) { + pub fn rect_2d(&mut self, position: Vec2, rotation: f32, size: Vec2, color: LegacyColor) { if !self.enabled { return; } @@ -571,14 +580,14 @@ impl<'w, 's, T: GizmoConfigGroup> Gizmos<'w, 's, T> { } #[inline] - fn extend_list_colors(&mut self, colors: impl IntoIterator) { + fn extend_list_colors(&mut self, colors: impl IntoIterator) { self.buffer .list_colors .extend(colors.into_iter().map(|color| color.as_linear_rgba_f32())); } #[inline] - fn add_list_color(&mut self, color: Color, count: usize) { + fn add_list_color(&mut self, color: LegacyColor, count: usize) { self.buffer .list_colors .extend(iter::repeat(color.as_linear_rgba_f32()).take(count)); @@ -601,7 +610,7 @@ pub struct SphereBuilder<'a, 'w, 's, T: GizmoConfigGroup> { position: Vec3, rotation: Quat, radius: f32, - color: Color, + color: LegacyColor, circle_segments: usize, } diff --git a/crates/bevy_gizmos/src/lib.rs b/crates/bevy_gizmos/src/lib.rs index fe6e16553aa0d6..e5828990e7aa91 100644 --- a/crates/bevy_gizmos/src/lib.rs +++ b/crates/bevy_gizmos/src/lib.rs @@ -6,7 +6,7 @@ //! # use bevy_render::prelude::*; //! # use bevy_math::prelude::*; //! fn system(mut gizmos: Gizmos) { -//! gizmos.line(Vec3::ZERO, Vec3::X, Color::GREEN); +//! gizmos.line(Vec3::ZERO, Vec3::X, LegacyColor::GREEN); //! } //! # bevy_ecs::system::assert_is_system(system); //! ``` diff --git a/crates/bevy_gizmos/src/primitives/dim2.rs b/crates/bevy_gizmos/src/primitives/dim2.rs index 1922a9de6c9325..c759a96044e215 100644 --- a/crates/bevy_gizmos/src/primitives/dim2.rs +++ b/crates/bevy_gizmos/src/primitives/dim2.rs @@ -9,7 +9,7 @@ use bevy_math::primitives::{ Polygon, Polyline2d, Primitive2d, Rectangle, RegularPolygon, Segment2d, Triangle2d, }; use bevy_math::{Mat2, Vec2}; -use bevy_render::color::Color; +use bevy_render::color::LegacyColor; use crate::prelude::{GizmoConfigGroup, Gizmos}; @@ -32,7 +32,7 @@ pub trait GizmoPrimitive2d { primitive: P, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_>; } @@ -46,7 +46,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d for Gizmos<'w, ' primitive: Direction2d, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -70,7 +70,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d for Gizmos<'w, 's, T> primitive: Circle, position: Vec2, _angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -90,7 +90,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d for Gizmos<'w, 's, T primitive: Ellipse, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -110,7 +110,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d for Gizmos<'w, 's, primitive: Capsule2d, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -165,9 +165,9 @@ pub struct Line2dBuilder<'a, 'w, 's, T: GizmoConfigGroup> { direction: Direction2d, // Direction of the line - position: Vec2, // position of the center of the line - rotation: Mat2, // rotation of the line - color: Color, // color of the line + position: Vec2, // position of the center of the line + rotation: Mat2, // rotation of the line + color: LegacyColor, // color of the line draw_arrow: bool, // decides whether to indicate the direction of the line with an arrow } @@ -188,7 +188,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d for Gizmos<'w, 's, T> primitive: Line2d, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { Line2dBuilder { gizmos: self, @@ -239,7 +239,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d for Gizmos<'w, 's, T primitive: Plane2d, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -285,9 +285,9 @@ pub struct Segment2dBuilder<'a, 'w, 's, T: GizmoConfigGroup> { direction: Direction2d, // Direction of the line segment half_length: f32, // Half-length of the line segment - position: Vec2, // position of the center of the line segment - rotation: Mat2, // rotation of the line segment - color: Color, // color of the line segment + position: Vec2, // position of the center of the line segment + rotation: Mat2, // rotation of the line segment + color: LegacyColor, // color of the line segment draw_arrow: bool, // decides whether to draw just a line or an arrow } @@ -308,7 +308,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d for Gizmos<'w, 's, primitive: Segment2d, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { Segment2dBuilder { gizmos: self, @@ -354,7 +354,7 @@ impl<'w, 's, const N: usize, T: GizmoConfigGroup> GizmoPrimitive2d primitive: Polyline2d, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -381,7 +381,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d for Gizmos<' primitive: BoxedPolyline2d, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -408,7 +408,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d for Gizmos<'w, 's primitive: Triangle2d, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -429,7 +429,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d for Gizmos<'w, 's, primitive: Rectangle, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -459,7 +459,7 @@ impl<'w, 's, const N: usize, T: GizmoConfigGroup> GizmoPrimitive2d> primitive: Polygon, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -496,7 +496,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d for Gizmos<'w, primitive: BoxedPolygon, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -531,7 +531,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d for Gizmos<'w primitive: RegularPolygon, position: Vec2, angle: f32, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; diff --git a/crates/bevy_gizmos/src/primitives/dim3.rs b/crates/bevy_gizmos/src/primitives/dim3.rs index feb4b558f62816..a417b32ef0c43c 100644 --- a/crates/bevy_gizmos/src/primitives/dim3.rs +++ b/crates/bevy_gizmos/src/primitives/dim3.rs @@ -8,7 +8,7 @@ use bevy_math::primitives::{ Plane3d, Polyline3d, Primitive3d, Segment3d, Sphere, Torus, }; use bevy_math::{Quat, Vec3}; -use bevy_render::color::Color; +use bevy_render::color::LegacyColor; use crate::prelude::{GizmoConfigGroup, Gizmos}; @@ -29,7 +29,7 @@ pub trait GizmoPrimitive3d { primitive: P, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_>; } @@ -43,7 +43,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<'w, ' primitive: Direction3d, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { self.arrow(position, position + (rotation * *primitive), color); } @@ -63,7 +63,7 @@ pub struct SphereBuilder<'a, 'w, 's, T: GizmoConfigGroup> { // Center position of the sphere in 3D space position: Vec3, // Color of the sphere - color: Color, + color: LegacyColor, // Number of segments used to approximate the sphere geometry segments: usize, @@ -85,7 +85,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<'w, 's, T> primitive: Sphere, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { SphereBuilder { gizmos: self, @@ -146,7 +146,7 @@ pub struct Plane3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> { // Center position of the sphere in 3D space position: Vec3, // Color of the sphere - color: Color, + color: LegacyColor, // Number of axis to hint the plane axis_count: usize, @@ -184,7 +184,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<'w, 's, T primitive: Plane3d, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { Plane3dBuilder { gizmos: self, @@ -251,7 +251,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<'w, 's, T> primitive: Line3d, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -278,7 +278,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<'w, 's, primitive: Segment3d, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -303,7 +303,7 @@ impl<'w, 's, const N: usize, T: GizmoConfigGroup> GizmoPrimitive3d primitive: Polyline3d, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -328,7 +328,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<' primitive: BoxedPolyline3d, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -355,7 +355,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<'w, 's, T> primitive: Cuboid, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { if !self.enabled { return; @@ -417,7 +417,7 @@ pub struct Cylinder3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> { // default orientation is: the cylinder is aligned with `Vec3::Y` axis rotation: Quat, // Color of the cylinder - color: Color, + color: LegacyColor, // Number of segments used to approximate the cylinder geometry segments: usize, @@ -439,7 +439,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<'w, 's, primitive: Cylinder, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { Cylinder3dBuilder { gizmos: self, @@ -514,7 +514,7 @@ pub struct Capsule3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> { // default orientation is: the capsule is aligned with `Vec3::Y` axis rotation: Quat, // Color of the capsule - color: Color, + color: LegacyColor, // Number of segments used to approximate the capsule geometry segments: usize, @@ -536,7 +536,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<'w, 's, primitive: Capsule3d, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { Capsule3dBuilder { gizmos: self, @@ -607,7 +607,7 @@ pub struct Cone3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> { // default orientation is: cone base normal is aligned with the `Vec3::Y` axis rotation: Quat, // Color of the cone - color: Color, + color: LegacyColor, // Number of segments used to approximate the cone geometry segments: usize, @@ -629,7 +629,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<'w, 's, T> { primitive: Cone, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { Cone3dBuilder { gizmos: self, @@ -703,7 +703,7 @@ pub struct ConicalFrustum3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> { // default orientation is: conical frustum base shape normals are aligned with `Vec3::Y` axis rotation: Quat, // Color of the conical frustum - color: Color, + color: LegacyColor, // Number of segments used to approximate the curved surfaces segments: usize, @@ -725,7 +725,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<'w primitive: ConicalFrustum, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { ConicalFrustum3dBuilder { gizmos: self, @@ -807,7 +807,7 @@ pub struct Torus3dBuilder<'a, 'w, 's, T: GizmoConfigGroup> { // default orientation is: major circle normal is aligned with `Vec3::Y` axis rotation: Quat, // Color of the torus - color: Color, + color: LegacyColor, // Number of segments in the minor (tube) direction minor_segments: usize, @@ -837,7 +837,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d for Gizmos<'w, 's, T> primitive: Torus, position: Vec3, rotation: Quat, - color: Color, + color: LegacyColor, ) -> Self::Output<'_> { Torus3dBuilder { gizmos: self, diff --git a/crates/bevy_gizmos/src/primitives/helpers.rs b/crates/bevy_gizmos/src/primitives/helpers.rs index 02d45f02207f7e..54669930c9d688 100644 --- a/crates/bevy_gizmos/src/primitives/helpers.rs +++ b/crates/bevy_gizmos/src/primitives/helpers.rs @@ -1,7 +1,7 @@ use std::f32::consts::TAU; use bevy_math::{Mat2, Quat, Vec2, Vec3}; -use bevy_render::color::Color; +use bevy_render::color::LegacyColor; use crate::prelude::{GizmoConfigGroup, Gizmos}; @@ -58,7 +58,7 @@ pub(crate) fn draw_semi_sphere( rotation: Quat, center: Vec3, top: Vec3, - color: Color, + color: LegacyColor, ) { circle_coordinates(radius, segments) .map(|p| Vec3::new(p.x, 0.0, p.y)) @@ -81,7 +81,7 @@ pub(crate) fn draw_circle_3d( segments: usize, rotation: Quat, translation: Vec3, - color: Color, + color: LegacyColor, ) { let positions = (0..=segments) .map(|frac| frac as f32 / segments as f32) @@ -100,7 +100,7 @@ pub(crate) fn draw_cylinder_vertical_lines( half_height: f32, rotation: Quat, center: Vec3, - color: Color, + color: LegacyColor, ) { circle_coordinates(radius, segments) .map(move |point_2d| { diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index b3306ef3d0b1d2..63336cfdfcaae1 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -17,7 +17,7 @@ use bevy_pbr::{ use bevy_render::{ alpha::AlphaMode, camera::{Camera, OrthographicProjection, PerspectiveProjection, Projection, ScalingMode}, - color::Color, + color::LegacyColor, mesh::{ morph::{MeshMorphWeights, MorphAttributes, MorphTargetImage, MorphWeights}, skinning::{SkinnedMesh, SkinnedMeshInverseBindposes}, @@ -918,7 +918,7 @@ fn load_material( let ior = material.ior().unwrap_or(1.5); StandardMaterial { - base_color: Color::rgba_linear(color[0], color[1], color[2], color[3]), + base_color: LegacyColor::rgba_linear(color[0], color[1], color[2], color[3]), base_color_texture, perceptual_roughness: pbr.roughness_factor(), metallic: pbr.metallic_factor(), @@ -933,7 +933,7 @@ fn load_material( Some(Face::Back) }, occlusion_texture, - emissive: Color::rgb_linear(emissive[0], emissive[1], emissive[2]) + emissive: LegacyColor::rgb_linear(emissive[0], emissive[1], emissive[2]) * material.emissive_strength().unwrap_or(1.0), emissive_texture, specular_transmission, @@ -944,7 +944,7 @@ fn load_material( thickness_texture, ior, attenuation_distance, - attenuation_color: Color::rgb_linear( + attenuation_color: LegacyColor::rgb_linear( attenuation_color[0], attenuation_color[1], attenuation_color[2], @@ -1173,7 +1173,7 @@ fn load_node( gltf::khr_lights_punctual::Kind::Directional => { let mut entity = parent.spawn(DirectionalLightBundle { directional_light: DirectionalLight { - color: Color::rgb_from_array(light.color()), + color: LegacyColor::rgb_from_array(light.color()), // NOTE: KHR_punctual_lights defines the intensity units for directional // lights in lux (lm/m^2) which is what we need. illuminance: light.intensity(), @@ -1193,7 +1193,7 @@ fn load_node( gltf::khr_lights_punctual::Kind::Point => { let mut entity = parent.spawn(PointLightBundle { point_light: PointLight { - color: Color::rgb_from_array(light.color()), + color: LegacyColor::rgb_from_array(light.color()), // NOTE: KHR_punctual_lights defines the intensity units for point lights in // candela (lm/sr) which is luminous intensity and we need luminous power. // For a point light, luminous power = 4 * pi * luminous intensity @@ -1219,7 +1219,7 @@ fn load_node( } => { let mut entity = parent.spawn(SpotLightBundle { spot_light: SpotLight { - color: Color::rgb_from_array(light.color()), + color: LegacyColor::rgb_from_array(light.color()), // NOTE: KHR_punctual_lights defines the intensity units for spot lights in // candela (lm/sr) which is luminous intensity and we need luminous power. // For a spot light, we map luminous power = 4 * pi * luminous intensity diff --git a/crates/bevy_internal/src/lib.rs b/crates/bevy_internal/src/lib.rs index 04d364493805c2..1d628a41575e49 100644 --- a/crates/bevy_internal/src/lib.rs +++ b/crates/bevy_internal/src/lib.rs @@ -178,7 +178,7 @@ pub mod gizmos { //! # use bevy_render::prelude::*; //! # use bevy_math::prelude::*; //! fn system(mut gizmos: Gizmos) { - //! gizmos.line(Vec3::ZERO, Vec3::X, Color::GREEN); + //! gizmos.line(Vec3::ZERO, Vec3::X, LegacyColor::GREEN); //! } //! # bevy_ecs::system::assert_is_system(system); //! ``` diff --git a/crates/bevy_pbr/src/fog.rs b/crates/bevy_pbr/src/fog.rs index 96e78d2ac58e1c..eacdf58c94c845 100644 --- a/crates/bevy_pbr/src/fog.rs +++ b/crates/bevy_pbr/src/fog.rs @@ -2,7 +2,7 @@ use crate::ReflectComponent; use bevy_ecs::prelude::*; use bevy_math::Vec3; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; -use bevy_render::{color::Color, extract_component::ExtractComponent, prelude::Camera}; +use bevy_render::{color::LegacyColor, extract_component::ExtractComponent, prelude::Camera}; /// Configures the “classic” computer graphics [distance fog](https://en.wikipedia.org/wiki/Distance_fog) effect, /// in which objects appear progressively more covered in atmospheric haze the further away they are from the camera. @@ -34,7 +34,7 @@ use bevy_render::{color::Color, extract_component::ExtractComponent, prelude::Ca /// }, /// // Add fog to the same entity /// FogSettings { -/// color: Color::WHITE, +/// color: LegacyColor::WHITE, /// falloff: FogFalloff::Exponential { density: 1e-3 }, /// ..Default::default() /// }, @@ -55,14 +55,14 @@ pub struct FogSettings { /// /// **Tip:** The alpha channel of the color can be used to “modulate” the fog effect without /// changing the fog falloff mode or parameters. - pub color: Color, + pub color: LegacyColor, /// Color used to modulate the influence of directional light colors on the /// fog, where the view direction aligns with each directional light direction, /// producing a “glow” or light dispersion effect. (e.g. around the sun) /// - /// Use [`Color::NONE`] to disable the effect. - pub directional_light_color: Color, + /// Use [`LegacyColor::NONE`] to disable the effect. + pub directional_light_color: LegacyColor, /// The exponent applied to the directional light alignment calculation. /// A higher value means a more concentrated “glow”. @@ -346,7 +346,7 @@ impl FogFalloff { /// [`FogFalloff::REVISED_KOSCHMIEDER_CONTRAST_THRESHOLD`]. pub fn from_visibility_color( visibility: f32, - extinction_inscattering_color: Color, + extinction_inscattering_color: LegacyColor, ) -> FogFalloff { FogFalloff::from_visibility_contrast_colors( visibility, @@ -362,12 +362,12 @@ impl FogFalloff { /// /// ## Tips /// - Alpha values of the provided colors can modulate the `extinction` and `inscattering` effects; - /// - Using an `extinction_color` of [`Color::WHITE`] or [`Color::NONE`] disables the extinction effect; - /// - Using an `inscattering_color` of [`Color::BLACK`] or [`Color::NONE`] disables the inscattering effect. + /// - Using an `extinction_color` of [`LegacyColor::WHITE`] or [`LegacyColor::NONE`] disables the extinction effect; + /// - Using an `inscattering_color` of [`LegacyColor::BLACK`] or [`LegacyColor::NONE`] disables the inscattering effect. pub fn from_visibility_colors( visibility: f32, - extinction_color: Color, - inscattering_color: Color, + extinction_color: LegacyColor, + inscattering_color: LegacyColor, ) -> FogFalloff { FogFalloff::from_visibility_contrast_colors( visibility, @@ -382,7 +382,7 @@ impl FogFalloff { pub fn from_visibility_contrast_color( visibility: f32, contrast_threshold: f32, - extinction_inscattering_color: Color, + extinction_inscattering_color: LegacyColor, ) -> FogFalloff { FogFalloff::from_visibility_contrast_colors( visibility, @@ -397,13 +397,13 @@ impl FogFalloff { /// /// ## Tips /// - Alpha values of the provided colors can modulate the `extinction` and `inscattering` effects; - /// - Using an `extinction_color` of [`Color::WHITE`] or [`Color::NONE`] disables the extinction effect; - /// - Using an `inscattering_color` of [`Color::BLACK`] or [`Color::NONE`] disables the inscattering effect. + /// - Using an `extinction_color` of [`LegacyColor::WHITE`] or [`LegacyColor::NONE`] disables the extinction effect; + /// - Using an `inscattering_color` of [`LegacyColor::BLACK`] or [`LegacyColor::NONE`] disables the inscattering effect. pub fn from_visibility_contrast_colors( visibility: f32, contrast_threshold: f32, - extinction_color: Color, - inscattering_color: Color, + extinction_color: LegacyColor, + inscattering_color: LegacyColor, ) -> FogFalloff { use std::f32::consts::E; @@ -465,12 +465,12 @@ impl FogFalloff { impl Default for FogSettings { fn default() -> Self { FogSettings { - color: Color::rgba(1.0, 1.0, 1.0, 1.0), + color: LegacyColor::rgba(1.0, 1.0, 1.0, 1.0), falloff: FogFalloff::Linear { start: 0.0, end: 100.0, }, - directional_light_color: Color::NONE, + directional_light_color: LegacyColor::NONE, directional_light_exponent: 8.0, } } diff --git a/crates/bevy_pbr/src/lib.rs b/crates/bevy_pbr/src/lib.rs index 091348c938ec32..e13b2e9521faa1 100644 --- a/crates/bevy_pbr/src/lib.rs +++ b/crates/bevy_pbr/src/lib.rs @@ -73,7 +73,7 @@ use bevy_render::{ camera::{CameraUpdateSystem, Projection}, extract_component::ExtractComponentPlugin, extract_resource::ExtractResourcePlugin, - prelude::Color, + prelude::LegacyColor, render_asset::prepare_assets, render_graph::RenderGraph, render_phase::sort_phase_system, @@ -336,7 +336,7 @@ impl Plugin for PbrPlugin { app.world.resource_mut::>().insert( Handle::::default(), StandardMaterial { - base_color: Color::rgb(1.0, 0.0, 0.5), + base_color: LegacyColor::rgb(1.0, 0.0, 0.5), unlit: true, ..Default::default() }, diff --git a/crates/bevy_pbr/src/light.rs b/crates/bevy_pbr/src/light.rs index 9b2bd0880cee88..a285f0a9cf56e1 100644 --- a/crates/bevy_pbr/src/light.rs +++ b/crates/bevy_pbr/src/light.rs @@ -8,7 +8,7 @@ use bevy_math::{ use bevy_reflect::prelude::*; use bevy_render::{ camera::{Camera, CameraProjection}, - color::Color, + color::LegacyColor, extract_component::ExtractComponent, extract_resource::ExtractResource, primitives::{Aabb, CascadesFrusta, CubemapFrusta, Frustum, HalfSpace, Sphere}, @@ -98,7 +98,7 @@ pub mod light_consts { #[derive(Component, Debug, Clone, Copy, Reflect)] #[reflect(Component, Default)] pub struct PointLight { - pub color: Color, + pub color: LegacyColor, /// Luminous power in lumens, representing the amount of light emitted by this source in all directions. pub intensity: f32, pub range: f32, @@ -114,7 +114,7 @@ pub struct PointLight { impl Default for PointLight { fn default() -> Self { PointLight { - color: Color::rgb(1.0, 1.0, 1.0), + color: LegacyColor::rgb(1.0, 1.0, 1.0), // 1,000,000 lumens is a very large "cinema light" capable of registering brightly at Bevy's // default "very overcast day" exposure level. For "indoor lighting" with a lower exposure, // this would be way too bright. @@ -152,7 +152,7 @@ impl Default for PointLightShadowMap { #[derive(Component, Debug, Clone, Copy, Reflect)] #[reflect(Component, Default)] pub struct SpotLight { - pub color: Color, + pub color: LegacyColor, /// Luminous power in lumens, representing the amount of light emitted by this source in all directions. pub intensity: f32, pub range: f32, @@ -185,7 +185,7 @@ impl Default for SpotLight { fn default() -> Self { // a quarter arc attenuating from the center Self { - color: Color::rgb(1.0, 1.0, 1.0), + color: LegacyColor::rgb(1.0, 1.0, 1.0), // 1,000,000 lumens is a very large "cinema light" capable of registering brightly at Bevy's // default "very overcast day" exposure level. For "indoor lighting" with a lower exposure, // this would be way too bright. @@ -251,7 +251,7 @@ impl Default for SpotLight { #[derive(Component, Debug, Clone, Reflect)] #[reflect(Component, Default)] pub struct DirectionalLight { - pub color: Color, + pub color: LegacyColor, /// Illuminance in lux (lumens per square meter), representing the amount of /// light projected onto surfaces by this light source. Lux is used here /// instead of lumens because a directional light illuminates all surfaces @@ -269,7 +269,7 @@ pub struct DirectionalLight { impl Default for DirectionalLight { fn default() -> Self { DirectionalLight { - color: Color::rgb(1.0, 1.0, 1.0), + color: LegacyColor::rgb(1.0, 1.0, 1.0), illuminance: light_consts::lux::AMBIENT_DAYLIGHT, shadows_enabled: false, shadow_depth_bias: Self::DEFAULT_SHADOW_DEPTH_BIAS, @@ -636,7 +636,7 @@ fn calculate_cascade( #[derive(Resource, Clone, Debug, ExtractResource, Reflect)] #[reflect(Resource)] pub struct AmbientLight { - pub color: Color, + pub color: LegacyColor, /// A direct scale factor multiplied with `color` before being passed to the shader. pub brightness: f32, } @@ -644,14 +644,14 @@ pub struct AmbientLight { impl Default for AmbientLight { fn default() -> Self { Self { - color: Color::WHITE, + color: LegacyColor::WHITE, brightness: 80.0, } } } impl AmbientLight { pub const NONE: AmbientLight = AmbientLight { - color: Color::WHITE, + color: LegacyColor::WHITE, brightness: 0.0, }; } diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index 48a9ef3b8abfc0..695f2db40bf45f 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -52,7 +52,7 @@ use self::{irradiance_volume::IrradianceVolume, prelude::EnvironmentMapLight}; /// # use bevy_pbr::{Material, MaterialMeshBundle}; /// # use bevy_ecs::prelude::*; /// # use bevy_reflect::TypePath; -/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::Color}; +/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::LegacyColor}; /// # use bevy_asset::{Handle, AssetServer, Assets, Asset}; /// /// #[derive(AsBindGroup, Debug, Clone, Asset, TypePath)] @@ -60,7 +60,7 @@ use self::{irradiance_volume::IrradianceVolume, prelude::EnvironmentMapLight}; /// // Uniform bindings must implement `ShaderType`, which will be used to convert the value to /// // its shader-compatible equivalent. Most core math types already implement `ShaderType`. /// #[uniform(0)] -/// color: Color, +/// color: LegacyColor, /// // Images can be bound as textures in shaders. If the Image's sampler is also needed, just /// // add the sampler attribute with a different binding index. /// #[texture(1)] @@ -80,7 +80,7 @@ use self::{irradiance_volume::IrradianceVolume, prelude::EnvironmentMapLight}; /// fn setup(mut commands: Commands, mut materials: ResMut>, asset_server: Res) { /// commands.spawn(MaterialMeshBundle { /// material: materials.add(CustomMaterial { -/// color: Color::RED, +/// color: LegacyColor::RED, /// color_texture: asset_server.load("some_image.png"), /// }), /// ..Default::default() diff --git a/crates/bevy_pbr/src/pbr_material.rs b/crates/bevy_pbr/src/pbr_material.rs index 231da8c9e43d08..29b271609c6fd9 100644 --- a/crates/bevy_pbr/src/pbr_material.rs +++ b/crates/bevy_pbr/src/pbr_material.rs @@ -2,8 +2,8 @@ use bevy_asset::{Asset, Handle}; use bevy_math::{Affine2, Vec2, Vec4}; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - color::Color, mesh::MeshVertexBufferLayout, render_asset::RenderAssets, render_resource::*, - texture::Image, + color::LegacyColor, mesh::MeshVertexBufferLayout, render_asset::RenderAssets, + render_resource::*, texture::Image, }; use crate::deferred::DEFAULT_PBR_DEFERRED_LIGHTING_PASS_ID; @@ -13,7 +13,7 @@ use crate::*; /// Standard property values with pictures here /// . /// -/// May be created directly from a [`Color`] or an [`Image`]. +/// May be created directly from a [`LegacyColor`] or an [`Image`]. #[derive(Asset, AsBindGroup, Reflect, Debug, Clone)] #[bind_group_data(StandardMaterialKey)] #[uniform(0, StandardMaterialUniform)] @@ -25,15 +25,15 @@ pub struct StandardMaterial { /// in between. If used together with a `base_color_texture`, this is factored into the final /// base color as `base_color * base_color_texture_value` /// - /// Defaults to [`Color::WHITE`]. - pub base_color: Color, + /// Defaults to [`LegacyColor::WHITE`]. + pub base_color: LegacyColor, /// The texture component of the material's color before lighting. /// The actual pre-lighting color is `base_color * this_texture`. /// /// See [`base_color`] for details. /// - /// You should set `base_color` to [`Color::WHITE`] (the default) + /// You should set `base_color` to [`LegacyColor::WHITE`] (the default) /// if you want the texture to show as-is. /// /// Setting `base_color` to something else than white will tint @@ -61,13 +61,13 @@ pub struct StandardMaterial { /// /// Note that **an emissive material won't light up surrounding areas like a light source**, /// it just adds a value to the color seen on screen. - pub emissive: Color, + pub emissive: LegacyColor, /// The emissive map, multiplies pixels with [`emissive`] /// to get the final "emitting" color of a surface. /// /// This color is multiplied by [`emissive`] to get the final emitted color. - /// Meaning that you should set [`emissive`] to [`Color::WHITE`] + /// Meaning that you should set [`emissive`] to [`LegacyColor::WHITE`] /// if you want to use the full range of color of the emissive texture. /// /// [`emissive`]: StandardMaterial::emissive @@ -274,7 +274,7 @@ pub struct StandardMaterial { /// The resulting (non-absorbed) color after white light travels through the attenuation distance. /// - /// Defaults to [`Color::WHITE`], i.e. no change. + /// Defaults to [`LegacyColor::WHITE`], i.e. no change. /// /// **Note:** To have any effect, must be used in conjunction with: /// - [`StandardMaterial::attenuation_distance`]; @@ -282,7 +282,7 @@ pub struct StandardMaterial { /// - [`StandardMaterial::diffuse_transmission`] or [`StandardMaterial::specular_transmission`]. #[doc(alias = "absorption_color")] #[doc(alias = "extinction_color")] - pub attenuation_color: Color, + pub attenuation_color: LegacyColor, /// Used to fake the lighting of bumps and dents on a material. /// @@ -482,9 +482,9 @@ impl Default for StandardMaterial { StandardMaterial { // White because it gets multiplied with texture values if someone uses // a texture. - base_color: Color::rgb(1.0, 1.0, 1.0), + base_color: LegacyColor::rgb(1.0, 1.0, 1.0), base_color_texture: None, - emissive: Color::BLACK, + emissive: LegacyColor::BLACK, emissive_texture: None, // Matches Blender's default roughness. perceptual_roughness: 0.5, @@ -505,7 +505,7 @@ impl Default for StandardMaterial { #[cfg(feature = "pbr_transmission_textures")] thickness_texture: None, ior: 1.5, - attenuation_color: Color::WHITE, + attenuation_color: LegacyColor::WHITE, attenuation_distance: f32::INFINITY, occlusion_texture: None, normal_map_texture: None, @@ -528,8 +528,8 @@ impl Default for StandardMaterial { } } -impl From for StandardMaterial { - fn from(color: Color) -> Self { +impl From for StandardMaterial { + fn from(color: LegacyColor) -> Self { StandardMaterial { base_color: color, alpha_mode: if color.a() < 1.0 { diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 84834b15b39c5c..cc7cf9057cf827 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -4,7 +4,7 @@ use bevy_ecs::prelude::*; use bevy_math::{Mat4, UVec3, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles}; use bevy_render::{ camera::Camera, - color::Color, + color::LegacyColor, mesh::Mesh, primitives::{CascadesFrusta, CubemapFrusta, Frustum}, render_asset::RenderAssets, @@ -29,7 +29,7 @@ use crate::*; #[derive(Component)] pub struct ExtractedPointLight { - pub color: Color, + pub color: LegacyColor, /// luminous intensity in lumens per steradian pub intensity: f32, pub range: f32, @@ -43,7 +43,7 @@ pub struct ExtractedPointLight { #[derive(Component, Debug)] pub struct ExtractedDirectionalLight { - pub color: Color, + pub color: LegacyColor, pub illuminance: f32, pub transform: GlobalTransform, pub shadows_enabled: bool, diff --git a/crates/bevy_pbr/src/wireframe.rs b/crates/bevy_pbr/src/wireframe.rs index b21374c25bbd47..563d952c1e0b7d 100644 --- a/crates/bevy_pbr/src/wireframe.rs +++ b/crates/bevy_pbr/src/wireframe.rs @@ -4,7 +4,7 @@ use bevy_asset::{load_internal_asset, Asset, Assets, Handle}; use bevy_ecs::prelude::*; use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath}; use bevy_render::{ - color::Color, + color::LegacyColor, extract_resource::ExtractResource, mesh::{Mesh, MeshVertexBufferLayout}, prelude::*, @@ -69,7 +69,7 @@ pub struct Wireframe; #[derive(Component, Debug, Clone, Default, Reflect)] #[reflect(Component, Default)] pub struct WireframeColor { - pub color: Color, + pub color: LegacyColor, } /// Disables wireframe rendering for any entity it is attached to. @@ -89,7 +89,7 @@ pub struct WireframeConfig { /// If [`Self::global`] is set, any [`Entity`] that does not have a [`Wireframe`] component attached to it will have /// wireframes using this color. Otherwise, this will be the fallback color for any entity that has a [`Wireframe`], /// but no [`WireframeColor`]. - pub default_color: Color, + pub default_color: LegacyColor, } #[derive(Resource)] @@ -200,7 +200,7 @@ fn apply_global_wireframe_material( #[derive(Default, AsBindGroup, TypePath, Debug, Clone, Asset)] pub struct WireframeMaterial { #[uniform(0)] - pub color: Color, + pub color: LegacyColor, } impl Material for WireframeMaterial { diff --git a/crates/bevy_render/src/camera/clear_color.rs b/crates/bevy_render/src/camera/clear_color.rs index 952e22ad976fd1..9a549fe3c48dd8 100644 --- a/crates/bevy_render/src/camera/clear_color.rs +++ b/crates/bevy_render/src/camera/clear_color.rs @@ -1,4 +1,4 @@ -use crate::{color::Color, extract_resource::ExtractResource}; +use crate::{color::LegacyColor, extract_resource::ExtractResource}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::prelude::*; use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize}; @@ -12,15 +12,15 @@ pub enum ClearColorConfig { #[default] Default, /// The given clear color is used, overriding the [`ClearColor`] resource defined in the world. - Custom(Color), + Custom(LegacyColor), /// No clear color is used: the camera will simply draw on top of anything already in the viewport. /// /// This can be useful when multiple cameras are rendering to the same viewport. None, } -impl From for ClearColorConfig { - fn from(color: Color) -> Self { +impl From for ClearColorConfig { + fn from(color: LegacyColor) -> Self { Self::Custom(color) } } @@ -31,11 +31,11 @@ impl From for ClearColorConfig { /// when there are portions of the screen with nothing rendered. #[derive(Resource, Clone, Debug, Deref, DerefMut, ExtractResource, Reflect)] #[reflect(Resource)] -pub struct ClearColor(pub Color); +pub struct ClearColor(pub LegacyColor); /// Match the dark gray bevy website code block color by default. impl Default for ClearColor { fn default() -> Self { - Self(Color::rgb_u8(43, 44, 47)) + Self(LegacyColor::rgb_u8(43, 44, 47)) } } diff --git a/crates/bevy_render/src/color/mod.rs b/crates/bevy_render/src/color/mod.rs index dbe28a11acce64..5561bd4a68fa5f 100644 --- a/crates/bevy_render/src/color/mod.rs +++ b/crates/bevy_render/src/color/mod.rs @@ -10,7 +10,7 @@ use thiserror::Error; #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Reflect)] #[reflect(PartialEq, Serialize, Deserialize)] -pub enum Color { +pub enum LegacyColor { /// sRGBA color Rgba { /// Red channel. [0.0, 1.0] @@ -57,84 +57,84 @@ pub enum Color { }, } -impl Color { +impl LegacyColor { ///
- pub const ALICE_BLUE: Color = Color::rgb(0.94, 0.97, 1.0); + pub const ALICE_BLUE: LegacyColor = LegacyColor::rgb(0.94, 0.97, 1.0); ///
- pub const ANTIQUE_WHITE: Color = Color::rgb(0.98, 0.92, 0.84); + pub const ANTIQUE_WHITE: LegacyColor = LegacyColor::rgb(0.98, 0.92, 0.84); ///
- pub const AQUAMARINE: Color = Color::rgb(0.49, 1.0, 0.83); + pub const AQUAMARINE: LegacyColor = LegacyColor::rgb(0.49, 1.0, 0.83); ///
- pub const AZURE: Color = Color::rgb(0.94, 1.0, 1.0); + pub const AZURE: LegacyColor = LegacyColor::rgb(0.94, 1.0, 1.0); ///
- pub const BEIGE: Color = Color::rgb(0.96, 0.96, 0.86); + pub const BEIGE: LegacyColor = LegacyColor::rgb(0.96, 0.96, 0.86); ///
- pub const BISQUE: Color = Color::rgb(1.0, 0.89, 0.77); + pub const BISQUE: LegacyColor = LegacyColor::rgb(1.0, 0.89, 0.77); ///
- pub const BLACK: Color = Color::rgb(0.0, 0.0, 0.0); + pub const BLACK: LegacyColor = LegacyColor::rgb(0.0, 0.0, 0.0); ///
- pub const BLUE: Color = Color::rgb(0.0, 0.0, 1.0); + pub const BLUE: LegacyColor = LegacyColor::rgb(0.0, 0.0, 1.0); ///
- pub const CRIMSON: Color = Color::rgb(0.86, 0.08, 0.24); + pub const CRIMSON: LegacyColor = LegacyColor::rgb(0.86, 0.08, 0.24); ///
- pub const CYAN: Color = Color::rgb(0.0, 1.0, 1.0); + pub const CYAN: LegacyColor = LegacyColor::rgb(0.0, 1.0, 1.0); ///
- pub const DARK_GRAY: Color = Color::rgb(0.25, 0.25, 0.25); + pub const DARK_GRAY: LegacyColor = LegacyColor::rgb(0.25, 0.25, 0.25); ///
- pub const DARK_GREEN: Color = Color::rgb(0.0, 0.5, 0.0); + pub const DARK_GREEN: LegacyColor = LegacyColor::rgb(0.0, 0.5, 0.0); ///
- pub const FUCHSIA: Color = Color::rgb(1.0, 0.0, 1.0); + pub const FUCHSIA: LegacyColor = LegacyColor::rgb(1.0, 0.0, 1.0); ///
- pub const GOLD: Color = Color::rgb(1.0, 0.84, 0.0); + pub const GOLD: LegacyColor = LegacyColor::rgb(1.0, 0.84, 0.0); ///
- pub const GRAY: Color = Color::rgb(0.5, 0.5, 0.5); + pub const GRAY: LegacyColor = LegacyColor::rgb(0.5, 0.5, 0.5); ///
- pub const GREEN: Color = Color::rgb(0.0, 1.0, 0.0); + pub const GREEN: LegacyColor = LegacyColor::rgb(0.0, 1.0, 0.0); ///
- pub const INDIGO: Color = Color::rgb(0.29, 0.0, 0.51); + pub const INDIGO: LegacyColor = LegacyColor::rgb(0.29, 0.0, 0.51); ///
- pub const LIME_GREEN: Color = Color::rgb(0.2, 0.8, 0.2); + pub const LIME_GREEN: LegacyColor = LegacyColor::rgb(0.2, 0.8, 0.2); ///
- pub const MAROON: Color = Color::rgb(0.5, 0.0, 0.0); + pub const MAROON: LegacyColor = LegacyColor::rgb(0.5, 0.0, 0.0); ///
- pub const MIDNIGHT_BLUE: Color = Color::rgb(0.1, 0.1, 0.44); + pub const MIDNIGHT_BLUE: LegacyColor = LegacyColor::rgb(0.1, 0.1, 0.44); ///
- pub const NAVY: Color = Color::rgb(0.0, 0.0, 0.5); + pub const NAVY: LegacyColor = LegacyColor::rgb(0.0, 0.0, 0.5); ///
#[doc(alias = "transparent")] - pub const NONE: Color = Color::rgba(0.0, 0.0, 0.0, 0.0); + pub const NONE: LegacyColor = LegacyColor::rgba(0.0, 0.0, 0.0, 0.0); ///
- pub const OLIVE: Color = Color::rgb(0.5, 0.5, 0.0); + pub const OLIVE: LegacyColor = LegacyColor::rgb(0.5, 0.5, 0.0); ///
- pub const ORANGE: Color = Color::rgb(1.0, 0.65, 0.0); + pub const ORANGE: LegacyColor = LegacyColor::rgb(1.0, 0.65, 0.0); ///
- pub const ORANGE_RED: Color = Color::rgb(1.0, 0.27, 0.0); + pub const ORANGE_RED: LegacyColor = LegacyColor::rgb(1.0, 0.27, 0.0); ///
- pub const PINK: Color = Color::rgb(1.0, 0.08, 0.58); + pub const PINK: LegacyColor = LegacyColor::rgb(1.0, 0.08, 0.58); ///
- pub const PURPLE: Color = Color::rgb(0.5, 0.0, 0.5); + pub const PURPLE: LegacyColor = LegacyColor::rgb(0.5, 0.0, 0.5); ///
- pub const RED: Color = Color::rgb(1.0, 0.0, 0.0); + pub const RED: LegacyColor = LegacyColor::rgb(1.0, 0.0, 0.0); ///
- pub const SALMON: Color = Color::rgb(0.98, 0.5, 0.45); + pub const SALMON: LegacyColor = LegacyColor::rgb(0.98, 0.5, 0.45); ///
- pub const SEA_GREEN: Color = Color::rgb(0.18, 0.55, 0.34); + pub const SEA_GREEN: LegacyColor = LegacyColor::rgb(0.18, 0.55, 0.34); ///
- pub const SILVER: Color = Color::rgb(0.75, 0.75, 0.75); + pub const SILVER: LegacyColor = LegacyColor::rgb(0.75, 0.75, 0.75); ///
- pub const TEAL: Color = Color::rgb(0.0, 0.5, 0.5); + pub const TEAL: LegacyColor = LegacyColor::rgb(0.0, 0.5, 0.5); ///
- pub const TOMATO: Color = Color::rgb(1.0, 0.39, 0.28); + pub const TOMATO: LegacyColor = LegacyColor::rgb(1.0, 0.39, 0.28); ///
- pub const TURQUOISE: Color = Color::rgb(0.25, 0.88, 0.82); + pub const TURQUOISE: LegacyColor = LegacyColor::rgb(0.25, 0.88, 0.82); ///
- pub const VIOLET: Color = Color::rgb(0.93, 0.51, 0.93); + pub const VIOLET: LegacyColor = LegacyColor::rgb(0.93, 0.51, 0.93); ///
- pub const WHITE: Color = Color::rgb(1.0, 1.0, 1.0); + pub const WHITE: LegacyColor = LegacyColor::rgb(1.0, 1.0, 1.0); ///
- pub const YELLOW: Color = Color::rgb(1.0, 1.0, 0.0); + pub const YELLOW: LegacyColor = LegacyColor::rgb(1.0, 1.0, 0.0); ///
- pub const YELLOW_GREEN: Color = Color::rgb(0.6, 0.8, 0.2); + pub const YELLOW_GREEN: LegacyColor = LegacyColor::rgb(0.6, 0.8, 0.2); /// New `Color` from sRGB colorspace. /// @@ -144,10 +144,10 @@ impl Color { /// * `g` - Green channel. [0.0, 1.0] /// * `b` - Blue channel. [0.0, 1.0] /// - /// See also [`Color::rgba`], [`Color::rgb_u8`], [`Color::hex`]. + /// See also [`LegacyColor::rgba`], [`LegacyColor::rgb_u8`], [`LegacyColor::hex`]. /// - pub const fn rgb(r: f32, g: f32, b: f32) -> Color { - Color::Rgba { + pub const fn rgb(r: f32, g: f32, b: f32) -> LegacyColor { + LegacyColor::Rgba { red: r, green: g, blue: b, @@ -164,10 +164,10 @@ impl Color { /// * `b` - Blue channel. [0.0, 1.0] /// * `a` - Alpha channel. [0.0, 1.0] /// - /// See also [`Color::rgb`], [`Color::rgba_u8`], [`Color::hex`]. + /// See also [`LegacyColor::rgb`], [`LegacyColor::rgba_u8`], [`LegacyColor::hex`]. /// - pub const fn rgba(r: f32, g: f32, b: f32, a: f32) -> Color { - Color::Rgba { + pub const fn rgba(r: f32, g: f32, b: f32, a: f32) -> LegacyColor { + LegacyColor::Rgba { red: r, green: g, blue: b, @@ -183,10 +183,10 @@ impl Color { /// * `g` - Green channel. [0.0, 1.0] /// * `b` - Blue channel. [0.0, 1.0] /// - /// See also [`Color::rgb`], [`Color::rgba_linear`]. + /// See also [`LegacyColor::rgb`], [`LegacyColor::rgba_linear`]. /// - pub const fn rgb_linear(r: f32, g: f32, b: f32) -> Color { - Color::RgbaLinear { + pub const fn rgb_linear(r: f32, g: f32, b: f32) -> LegacyColor { + LegacyColor::RgbaLinear { red: r, green: g, blue: b, @@ -203,10 +203,10 @@ impl Color { /// * `b` - Blue channel. [0.0, 1.0] /// * `a` - Alpha channel. [0.0, 1.0] /// - /// See also [`Color::rgba`], [`Color::rgb_linear`]. + /// See also [`LegacyColor::rgba`], [`LegacyColor::rgb_linear`]. /// - pub const fn rgba_linear(r: f32, g: f32, b: f32, a: f32) -> Color { - Color::RgbaLinear { + pub const fn rgba_linear(r: f32, g: f32, b: f32, a: f32) -> LegacyColor { + LegacyColor::RgbaLinear { red: r, green: g, blue: b, @@ -222,10 +222,10 @@ impl Color { /// * `saturation` - Saturation channel. [0.0, 1.0] /// * `lightness` - Lightness channel. [0.0, 1.0] /// - /// See also [`Color::hsla`]. + /// See also [`LegacyColor::hsla`]. /// - pub const fn hsl(hue: f32, saturation: f32, lightness: f32) -> Color { - Color::Hsla { + pub const fn hsl(hue: f32, saturation: f32, lightness: f32) -> LegacyColor { + LegacyColor::Hsla { hue, saturation, lightness, @@ -242,10 +242,10 @@ impl Color { /// * `lightness` - Lightness channel. [0.0, 1.0] /// * `alpha` - Alpha channel. [0.0, 1.0] /// - /// See also [`Color::hsl`]. + /// See also [`LegacyColor::hsl`]. /// - pub const fn hsla(hue: f32, saturation: f32, lightness: f32, alpha: f32) -> Color { - Color::Hsla { + pub const fn hsla(hue: f32, saturation: f32, lightness: f32, alpha: f32) -> LegacyColor { + LegacyColor::Hsla { hue, saturation, lightness, @@ -261,9 +261,9 @@ impl Color { /// * `chroma` - Chroma channel. [0.0, 1.5] /// * `hue` - Hue channel. [0.0, 360.0] /// - /// See also [`Color::lcha`]. - pub const fn lch(lightness: f32, chroma: f32, hue: f32) -> Color { - Color::Lcha { + /// See also [`LegacyColor::lcha`]. + pub const fn lch(lightness: f32, chroma: f32, hue: f32) -> LegacyColor { + LegacyColor::Lcha { lightness, chroma, hue, @@ -280,9 +280,9 @@ impl Color { /// * `hue` - Hue channel. [0.0, 360.0] /// * `alpha` - Alpha channel. [0.0, 1.0] /// - /// See also [`Color::lch`]. - pub const fn lcha(lightness: f32, chroma: f32, hue: f32, alpha: f32) -> Color { - Color::Lcha { + /// See also [`LegacyColor::lch`]. + pub const fn lcha(lightness: f32, chroma: f32, hue: f32, alpha: f32) -> LegacyColor { + LegacyColor::Lcha { lightness, chroma, hue, @@ -295,15 +295,15 @@ impl Color { /// # Examples /// /// ``` - /// # use bevy_render::color::Color; - /// let color = Color::hex("FF00FF").unwrap(); // fuchsia - /// let color = Color::hex("FF00FF7F").unwrap(); // partially transparent fuchsia + /// # use bevy_render::color::LegacyColor; + /// let color = LegacyColor::hex("FF00FF").unwrap(); // fuchsia + /// let color = LegacyColor::hex("FF00FF7F").unwrap(); // partially transparent fuchsia /// /// // A standard hex color notation is also available - /// assert_eq!(Color::hex("#FFFFFF").unwrap(), Color::rgb(1.0, 1.0, 1.0)); + /// assert_eq!(LegacyColor::hex("#FFFFFF").unwrap(), LegacyColor::rgb(1.0, 1.0, 1.0)); /// ``` /// - pub fn hex>(hex: T) -> Result { + pub fn hex>(hex: T) -> Result { let hex = hex.as_ref(); let hex = hex.strip_prefix('#').unwrap_or(hex); @@ -311,22 +311,22 @@ impl Color { // RGB [r, g, b] => { let [r, g, b, ..] = decode_hex([r, r, g, g, b, b])?; - Ok(Color::rgb_u8(r, g, b)) + Ok(LegacyColor::rgb_u8(r, g, b)) } // RGBA [r, g, b, a] => { let [r, g, b, a, ..] = decode_hex([r, r, g, g, b, b, a, a])?; - Ok(Color::rgba_u8(r, g, b, a)) + Ok(LegacyColor::rgba_u8(r, g, b, a)) } // RRGGBB [r1, r2, g1, g2, b1, b2] => { let [r, g, b, ..] = decode_hex([r1, r2, g1, g2, b1, b2])?; - Ok(Color::rgb_u8(r, g, b)) + Ok(LegacyColor::rgb_u8(r, g, b)) } // RRGGBBAA [r1, r2, g1, g2, b1, b2, a1, a2] => { let [r, g, b, a, ..] = decode_hex([r1, r2, g1, g2, b1, b2, a1, a2])?; - Ok(Color::rgba_u8(r, g, b, a)) + Ok(LegacyColor::rgba_u8(r, g, b, a)) } _ => Err(HexColorError::Length), } @@ -340,10 +340,10 @@ impl Color { /// * `g` - Green channel. [0, 255] /// * `b` - Blue channel. [0, 255] /// - /// See also [`Color::rgb`], [`Color::rgba_u8`], [`Color::hex`]. + /// See also [`LegacyColor::rgb`], [`LegacyColor::rgba_u8`], [`LegacyColor::hex`]. /// - pub fn rgb_u8(r: u8, g: u8, b: u8) -> Color { - Color::rgba_u8(r, g, b, u8::MAX) + pub fn rgb_u8(r: u8, g: u8, b: u8) -> LegacyColor { + LegacyColor::rgba_u8(r, g, b, u8::MAX) } // Float operations in const fn are not stable yet @@ -357,10 +357,10 @@ impl Color { /// * `b` - Blue channel. [0, 255] /// * `a` - Alpha channel. [0, 255] /// - /// See also [`Color::rgba`], [`Color::rgb_u8`], [`Color::hex`]. + /// See also [`LegacyColor::rgba`], [`LegacyColor::rgb_u8`], [`LegacyColor::hex`]. /// - pub fn rgba_u8(r: u8, g: u8, b: u8, a: u8) -> Color { - Color::rgba( + pub fn rgba_u8(r: u8, g: u8, b: u8, a: u8) -> LegacyColor { + LegacyColor::rgba( r as f32 / u8::MAX as f32, g as f32 / u8::MAX as f32, b as f32 / u8::MAX as f32, @@ -368,150 +368,150 @@ impl Color { ) } - /// Converts a Color to variant [`Color::Rgba`] and return red in sRGB colorspace + /// Converts a Color to variant [`LegacyColor::Rgba`] and return red in sRGB colorspace pub fn r(&self) -> f32 { match self.as_rgba() { - Color::Rgba { red, .. } => red, + LegacyColor::Rgba { red, .. } => red, _ => unreachable!(), } } - /// Converts a Color to variant [`Color::Rgba`] and return green in sRGB colorspace + /// Converts a Color to variant [`LegacyColor::Rgba`] and return green in sRGB colorspace pub fn g(&self) -> f32 { match self.as_rgba() { - Color::Rgba { green, .. } => green, + LegacyColor::Rgba { green, .. } => green, _ => unreachable!(), } } - /// Converts a Color to variant [`Color::Rgba`] and return blue in sRGB colorspace + /// Converts a Color to variant [`LegacyColor::Rgba`] and return blue in sRGB colorspace pub fn b(&self) -> f32 { match self.as_rgba() { - Color::Rgba { blue, .. } => blue, + LegacyColor::Rgba { blue, .. } => blue, _ => unreachable!(), } } - /// Converts a Color to variant [`Color::Rgba`] and set red + /// Converts a Color to variant [`LegacyColor::Rgba`] and set red pub fn set_r(&mut self, r: f32) -> &mut Self { *self = self.as_rgba(); match self { - Color::Rgba { red, .. } => *red = r, + LegacyColor::Rgba { red, .. } => *red = r, _ => unreachable!(), } self } - /// Converts a Color to variant [`Color::Rgba`] and return this color with red set to a new value + /// Converts a Color to variant [`LegacyColor::Rgba`] and return this color with red set to a new value #[must_use] pub fn with_r(mut self, r: f32) -> Self { self.set_r(r); self } - /// Converts a Color to variant [`Color::Rgba`] and set green + /// Converts a Color to variant [`LegacyColor::Rgba`] and set green pub fn set_g(&mut self, g: f32) -> &mut Self { *self = self.as_rgba(); match self { - Color::Rgba { green, .. } => *green = g, + LegacyColor::Rgba { green, .. } => *green = g, _ => unreachable!(), } self } - /// Converts a Color to variant [`Color::Rgba`] and return this color with green set to a new value + /// Converts a Color to variant [`LegacyColor::Rgba`] and return this color with green set to a new value #[must_use] pub fn with_g(mut self, g: f32) -> Self { self.set_g(g); self } - /// Converts a Color to variant [`Color::Rgba`] and set blue + /// Converts a Color to variant [`LegacyColor::Rgba`] and set blue pub fn set_b(&mut self, b: f32) -> &mut Self { *self = self.as_rgba(); match self { - Color::Rgba { blue, .. } => *blue = b, + LegacyColor::Rgba { blue, .. } => *blue = b, _ => unreachable!(), } self } - /// Converts a Color to variant [`Color::Rgba`] and return this color with blue set to a new value + /// Converts a Color to variant [`LegacyColor::Rgba`] and return this color with blue set to a new value #[must_use] pub fn with_b(mut self, b: f32) -> Self { self.set_b(b); self } - /// Converts a Color to variant [`Color::Hsla`] and return hue + /// Converts a Color to variant [`LegacyColor::Hsla`] and return hue pub fn h(&self) -> f32 { match self.as_hsla() { - Color::Hsla { hue, .. } => hue, + LegacyColor::Hsla { hue, .. } => hue, _ => unreachable!(), } } - /// Converts a Color to variant [`Color::Hsla`] and return saturation + /// Converts a Color to variant [`LegacyColor::Hsla`] and return saturation pub fn s(&self) -> f32 { match self.as_hsla() { - Color::Hsla { saturation, .. } => saturation, + LegacyColor::Hsla { saturation, .. } => saturation, _ => unreachable!(), } } - /// Converts a Color to variant [`Color::Hsla`] and return lightness + /// Converts a Color to variant [`LegacyColor::Hsla`] and return lightness pub fn l(&self) -> f32 { match self.as_hsla() { - Color::Hsla { lightness, .. } => lightness, + LegacyColor::Hsla { lightness, .. } => lightness, _ => unreachable!(), } } - /// Converts a Color to variant [`Color::Hsla`] and set hue + /// Converts a Color to variant [`LegacyColor::Hsla`] and set hue pub fn set_h(&mut self, h: f32) -> &mut Self { *self = self.as_hsla(); match self { - Color::Hsla { hue, .. } => *hue = h, + LegacyColor::Hsla { hue, .. } => *hue = h, _ => unreachable!(), } self } - /// Converts a Color to variant [`Color::Hsla`] and return this color with hue set to a new value + /// Converts a Color to variant [`LegacyColor::Hsla`] and return this color with hue set to a new value #[must_use] pub fn with_h(mut self, h: f32) -> Self { self.set_h(h); self } - /// Converts a Color to variant [`Color::Hsla`] and set saturation + /// Converts a Color to variant [`LegacyColor::Hsla`] and set saturation pub fn set_s(&mut self, s: f32) -> &mut Self { *self = self.as_hsla(); match self { - Color::Hsla { saturation, .. } => *saturation = s, + LegacyColor::Hsla { saturation, .. } => *saturation = s, _ => unreachable!(), } self } - /// Converts a Color to variant [`Color::Hsla`] and return this color with saturation set to a new value + /// Converts a Color to variant [`LegacyColor::Hsla`] and return this color with saturation set to a new value #[must_use] pub fn with_s(mut self, s: f32) -> Self { self.set_s(s); self } - /// Converts a Color to variant [`Color::Hsla`] and set lightness + /// Converts a Color to variant [`LegacyColor::Hsla`] and set lightness pub fn set_l(&mut self, l: f32) -> &mut Self { *self = self.as_hsla(); match self { - Color::Hsla { lightness, .. } => *lightness = l, + LegacyColor::Hsla { lightness, .. } => *lightness = l, _ => unreachable!(), } self } - /// Converts a Color to variant [`Color::Hsla`] and return this color with lightness set to a new value + /// Converts a Color to variant [`LegacyColor::Hsla`] and return this color with lightness set to a new value #[must_use] pub fn with_l(mut self, l: f32) -> Self { self.set_l(l); @@ -522,20 +522,20 @@ impl Color { #[inline(always)] pub fn a(&self) -> f32 { match self { - Color::Rgba { alpha, .. } - | Color::RgbaLinear { alpha, .. } - | Color::Hsla { alpha, .. } - | Color::Lcha { alpha, .. } => *alpha, + LegacyColor::Rgba { alpha, .. } + | LegacyColor::RgbaLinear { alpha, .. } + | LegacyColor::Hsla { alpha, .. } + | LegacyColor::Lcha { alpha, .. } => *alpha, } } /// Set alpha. pub fn set_a(&mut self, a: f32) -> &mut Self { match self { - Color::Rgba { alpha, .. } - | Color::RgbaLinear { alpha, .. } - | Color::Hsla { alpha, .. } - | Color::Lcha { alpha, .. } => { + LegacyColor::Rgba { alpha, .. } + | LegacyColor::RgbaLinear { alpha, .. } + | LegacyColor::Hsla { alpha, .. } + | LegacyColor::Lcha { alpha, .. } => { *alpha = a; } } @@ -554,36 +554,36 @@ impl Color { /// # Examples /// /// ``` - /// # use bevy_render::color::Color; + /// # use bevy_render::color::LegacyColor; /// // Fully transparent colors - /// assert!(Color::NONE.is_fully_transparent()); - /// assert!(Color::rgba(1.0, 0.5, 0.5, 0.0).is_fully_transparent()); + /// assert!(LegacyColor::NONE.is_fully_transparent()); + /// assert!(LegacyColor::rgba(1.0, 0.5, 0.5, 0.0).is_fully_transparent()); /// /// // (Partially) opaque colors - /// assert!(!Color::BLACK.is_fully_transparent()); - /// assert!(!Color::rgba(1.0, 0.5, 0.5, 0.2).is_fully_transparent()); + /// assert!(!LegacyColor::BLACK.is_fully_transparent()); + /// assert!(!LegacyColor::rgba(1.0, 0.5, 0.5, 0.2).is_fully_transparent()); /// ``` #[inline(always)] pub fn is_fully_transparent(&self) -> bool { self.a() == 0.0 } - /// Converts a `Color` to variant `Color::Rgba` - pub fn as_rgba(self: &Color) -> Color { + /// Converts a `Color` to variant `LegacyColor::Rgba` + pub fn as_rgba(self: &LegacyColor) -> LegacyColor { match self { - Color::Rgba { .. } => *self, - Color::RgbaLinear { + LegacyColor::Rgba { .. } => *self, + LegacyColor::RgbaLinear { red, green, blue, alpha, - } => Color::Rgba { + } => LegacyColor::Rgba { red: red.linear_to_nonlinear_srgb(), green: green.linear_to_nonlinear_srgb(), blue: blue.linear_to_nonlinear_srgb(), alpha: *alpha, }, - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -591,14 +591,14 @@ impl Color { } => { let [red, green, blue] = HslRepresentation::hsl_to_nonlinear_srgb(*hue, *saturation, *lightness); - Color::Rgba { + LegacyColor::Rgba { red, green, blue, alpha: *alpha, } } - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -607,7 +607,7 @@ impl Color { let [red, green, blue] = LchRepresentation::lch_to_nonlinear_srgb(*lightness, *chroma, *hue); - Color::Rgba { + LegacyColor::Rgba { red, green, blue, @@ -617,22 +617,22 @@ impl Color { } } - /// Converts a `Color` to variant `Color::RgbaLinear` - pub fn as_rgba_linear(self: &Color) -> Color { + /// Converts a `Color` to variant `LegacyColor::RgbaLinear` + pub fn as_rgba_linear(self: &LegacyColor) -> LegacyColor { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, alpha, - } => Color::RgbaLinear { + } => LegacyColor::RgbaLinear { red: red.nonlinear_to_linear_srgb(), green: green.nonlinear_to_linear_srgb(), blue: blue.nonlinear_to_linear_srgb(), alpha: *alpha, }, - Color::RgbaLinear { .. } => *self, - Color::Hsla { + LegacyColor::RgbaLinear { .. } => *self, + LegacyColor::Hsla { hue, saturation, lightness, @@ -640,14 +640,14 @@ impl Color { } => { let [red, green, blue] = HslRepresentation::hsl_to_nonlinear_srgb(*hue, *saturation, *lightness); - Color::RgbaLinear { + LegacyColor::RgbaLinear { red: red.nonlinear_to_linear_srgb(), green: green.nonlinear_to_linear_srgb(), blue: blue.nonlinear_to_linear_srgb(), alpha: *alpha, } } - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -656,7 +656,7 @@ impl Color { let [red, green, blue] = LchRepresentation::lch_to_nonlinear_srgb(*lightness, *chroma, *hue); - Color::RgbaLinear { + LegacyColor::RgbaLinear { red: red.nonlinear_to_linear_srgb(), green: green.nonlinear_to_linear_srgb(), blue: blue.nonlinear_to_linear_srgb(), @@ -666,10 +666,10 @@ impl Color { } } - /// Converts a `Color` to variant `Color::Hsla` - pub fn as_hsla(self: &Color) -> Color { + /// Converts a `Color` to variant `LegacyColor::Hsla` + pub fn as_hsla(self: &LegacyColor) -> LegacyColor { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, @@ -677,14 +677,14 @@ impl Color { } => { let (hue, saturation, lightness) = HslRepresentation::nonlinear_srgb_to_hsl([*red, *green, *blue]); - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, alpha: *alpha, } } - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, @@ -695,15 +695,15 @@ impl Color { green.linear_to_nonlinear_srgb(), blue.linear_to_nonlinear_srgb(), ]); - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, alpha: *alpha, } } - Color::Hsla { .. } => *self, - Color::Lcha { + LegacyColor::Hsla { .. } => *self, + LegacyColor::Lcha { lightness, chroma, hue, @@ -712,7 +712,7 @@ impl Color { let rgb = LchRepresentation::lch_to_nonlinear_srgb(*lightness, *chroma, *hue); let (hue, saturation, lightness) = HslRepresentation::nonlinear_srgb_to_hsl(rgb); - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -722,10 +722,10 @@ impl Color { } } - /// Converts a `Color` to variant `Color::Lcha` - pub fn as_lcha(self: &Color) -> Color { + /// Converts a `Color` to variant `LegacyColor::Lcha` + pub fn as_lcha(self: &LegacyColor) -> LegacyColor { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, @@ -733,14 +733,14 @@ impl Color { } => { let (lightness, chroma, hue) = LchRepresentation::nonlinear_srgb_to_lch([*red, *green, *blue]); - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, alpha: *alpha, } } - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, @@ -751,14 +751,14 @@ impl Color { green.linear_to_nonlinear_srgb(), blue.linear_to_nonlinear_srgb(), ]); - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, alpha: *alpha, } } - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -766,14 +766,14 @@ impl Color { } => { let rgb = HslRepresentation::hsl_to_nonlinear_srgb(*hue, *saturation, *lightness); let (lightness, chroma, hue) = LchRepresentation::nonlinear_srgb_to_lch(rgb); - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, alpha: *alpha, } } - Color::Lcha { .. } => *self, + LegacyColor::Lcha { .. } => *self, } } @@ -789,15 +789,15 @@ impl Color { } /// Converts a `Color` to a `[f32; 4]` from sRGB colorspace - pub fn as_rgba_f32(self: Color) -> [f32; 4] { + pub fn as_rgba_f32(self: LegacyColor) -> [f32; 4] { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, alpha, } => [red, green, blue, alpha], - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, @@ -808,7 +808,7 @@ impl Color { blue.linear_to_nonlinear_srgb(), alpha, ], - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -818,7 +818,7 @@ impl Color { HslRepresentation::hsl_to_nonlinear_srgb(hue, saturation, lightness); [red, green, blue, alpha] } - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -834,9 +834,9 @@ impl Color { /// Converts a `Color` to a `[f32; 4]` from linear RGB colorspace #[inline] - pub fn as_linear_rgba_f32(self: Color) -> [f32; 4] { + pub fn as_linear_rgba_f32(self: LegacyColor) -> [f32; 4] { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, @@ -847,13 +847,13 @@ impl Color { blue.nonlinear_to_linear_srgb(), alpha, ], - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, alpha, } => [red, green, blue, alpha], - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -868,7 +868,7 @@ impl Color { alpha, ] } - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -888,9 +888,9 @@ impl Color { } /// Converts a `Color` to a `[f32; 4]` from HSL colorspace - pub fn as_hsla_f32(self: Color) -> [f32; 4] { + pub fn as_hsla_f32(self: LegacyColor) -> [f32; 4] { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, @@ -900,7 +900,7 @@ impl Color { HslRepresentation::nonlinear_srgb_to_hsl([red, green, blue]); [hue, saturation, lightness, alpha] } - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, @@ -913,13 +913,13 @@ impl Color { ]); [hue, saturation, lightness, alpha] } - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, alpha, } => [hue, saturation, lightness, alpha], - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -934,9 +934,9 @@ impl Color { } /// Converts a `Color` to a `[f32; 4]` from LCH colorspace - pub fn as_lcha_f32(self: Color) -> [f32; 4] { + pub fn as_lcha_f32(self: LegacyColor) -> [f32; 4] { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, @@ -946,7 +946,7 @@ impl Color { LchRepresentation::nonlinear_srgb_to_lch([red, green, blue]); [lightness, chroma, hue, alpha] } - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, @@ -959,7 +959,7 @@ impl Color { ]); [lightness, chroma, hue, alpha] } - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -970,7 +970,7 @@ impl Color { [lightness, chroma, hue, alpha] } - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -983,9 +983,9 @@ impl Color { /// /// Maps the RGBA channels in RGBA order to a little-endian byte array (GPUs are little-endian). /// `A` will be the most significant byte and `R` the least significant. - pub fn as_rgba_u32(self: Color) -> u32 { + pub fn as_rgba_u32(self: LegacyColor) -> u32 { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, @@ -996,7 +996,7 @@ impl Color { (blue * 255.0) as u8, (alpha * 255.0) as u8, ]), - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, @@ -1007,7 +1007,7 @@ impl Color { (blue.linear_to_nonlinear_srgb() * 255.0) as u8, (alpha * 255.0) as u8, ]), - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -1022,7 +1022,7 @@ impl Color { (alpha * 255.0) as u8, ]) } - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -1045,9 +1045,9 @@ impl Color { /// /// Maps the RGBA channels in RGBA order to a little-endian byte array (GPUs are little-endian). /// `A` will be the most significant byte and `R` the least significant. - pub fn as_linear_rgba_u32(self: Color) -> u32 { + pub fn as_linear_rgba_u32(self: LegacyColor) -> u32 { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, @@ -1058,7 +1058,7 @@ impl Color { (blue.nonlinear_to_linear_srgb() * 255.0) as u8, (alpha * 255.0) as u8, ]), - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, @@ -1069,7 +1069,7 @@ impl Color { (blue * 255.0) as u8, (alpha * 255.0) as u8, ]), - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -1084,7 +1084,7 @@ impl Color { (alpha * 255.0) as u8, ]) } - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -1107,56 +1107,56 @@ impl Color { #[inline] pub fn rgba_from_array(arr: impl Into<[f32; 4]>) -> Self { let [r, g, b, a]: [f32; 4] = arr.into(); - Color::rgba(r, g, b, a) + LegacyColor::rgba(r, g, b, a) } /// New `Color` from `[f32; 3]` (or a type that can be converted into them) with RGB representation in sRGB colorspace. #[inline] pub fn rgb_from_array(arr: impl Into<[f32; 3]>) -> Self { let [r, g, b]: [f32; 3] = arr.into(); - Color::rgb(r, g, b) + LegacyColor::rgb(r, g, b) } /// New `Color` from `[f32; 4]` (or a type that can be converted into them) with RGB representation in linear RGB colorspace. #[inline] pub fn rgba_linear_from_array(arr: impl Into<[f32; 4]>) -> Self { let [r, g, b, a]: [f32; 4] = arr.into(); - Color::rgba_linear(r, g, b, a) + LegacyColor::rgba_linear(r, g, b, a) } /// New `Color` from `[f32; 3]` (or a type that can be converted into them) with RGB representation in linear RGB colorspace. #[inline] pub fn rgb_linear_from_array(arr: impl Into<[f32; 3]>) -> Self { let [r, g, b]: [f32; 3] = arr.into(); - Color::rgb_linear(r, g, b) + LegacyColor::rgb_linear(r, g, b) } /// New `Color` from `[f32; 4]` (or a type that can be converted into them) with HSL representation in sRGB colorspace. #[inline] pub fn hsla_from_array(arr: impl Into<[f32; 4]>) -> Self { let [h, s, l, a]: [f32; 4] = arr.into(); - Color::hsla(h, s, l, a) + LegacyColor::hsla(h, s, l, a) } /// New `Color` from `[f32; 3]` (or a type that can be converted into them) with HSL representation in sRGB colorspace. #[inline] pub fn hsl_from_array(arr: impl Into<[f32; 3]>) -> Self { let [h, s, l]: [f32; 3] = arr.into(); - Color::hsl(h, s, l) + LegacyColor::hsl(h, s, l) } /// New `Color` from `[f32; 4]` (or a type that can be converted into them) with LCH representation in sRGB colorspace. #[inline] pub fn lcha_from_array(arr: impl Into<[f32; 4]>) -> Self { let [l, c, h, a]: [f32; 4] = arr.into(); - Color::lcha(l, c, h, a) + LegacyColor::lcha(l, c, h, a) } /// New `Color` from `[f32; 3]` (or a type that can be converted into them) with LCH representation in sRGB colorspace. #[inline] pub fn lch_from_array(arr: impl Into<[f32; 3]>) -> Self { let [l, c, h]: [f32; 3] = arr.into(); - Color::lch(l, c, h) + LegacyColor::lch(l, c, h) } /// Convert `Color` to RGBA and return as `Vec4`. @@ -1164,7 +1164,7 @@ impl Color { pub fn rgba_to_vec4(&self) -> Vec4 { let color = self.as_rgba(); match color { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, @@ -1179,7 +1179,7 @@ impl Color { pub fn rgb_to_vec3(&self) -> Vec3 { let color = self.as_rgba(); match color { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, .. } => Vec3::new(red, green, blue), _ => unreachable!(), @@ -1191,7 +1191,7 @@ impl Color { pub fn rgba_linear_to_vec4(&self) -> Vec4 { let color = self.as_rgba_linear(); match color { - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, @@ -1206,7 +1206,7 @@ impl Color { pub fn rgb_linear_to_vec3(&self) -> Vec3 { let color = self.as_rgba_linear(); match color { - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, .. } => Vec3::new(red, green, blue), _ => unreachable!(), @@ -1218,7 +1218,7 @@ impl Color { pub fn hsla_to_vec4(&self) -> Vec4 { let color = self.as_hsla(); match color { - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -1233,7 +1233,7 @@ impl Color { pub fn hsl_to_vec3(&self) -> Vec3 { let color = self.as_hsla(); match color { - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -1248,7 +1248,7 @@ impl Color { pub fn lcha_to_vec4(&self) -> Vec4 { let color = self.as_lcha(); match color { - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -1263,7 +1263,7 @@ impl Color { pub fn lch_to_vec3(&self) -> Vec3 { let color = self.as_lcha(); match color { - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -1274,67 +1274,67 @@ impl Color { } } -impl Default for Color { +impl Default for LegacyColor { fn default() -> Self { - Color::WHITE + LegacyColor::WHITE } } -impl Add for Color { - type Output = Color; +impl Add for LegacyColor { + type Output = LegacyColor; - fn add(self, rhs: Color) -> Self::Output { + fn add(self, rhs: LegacyColor) -> Self::Output { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, alpha, } => { let rhs = rhs.as_rgba_f32(); - Color::Rgba { + LegacyColor::Rgba { red: red + rhs[0], green: green + rhs[1], blue: blue + rhs[2], alpha: alpha + rhs[3], } } - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, alpha, } => { let rhs = rhs.as_linear_rgba_f32(); - Color::RgbaLinear { + LegacyColor::RgbaLinear { red: red + rhs[0], green: green + rhs[1], blue: blue + rhs[2], alpha: alpha + rhs[3], } } - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, alpha, } => { let rhs = rhs.as_hsla_f32(); - Color::Hsla { + LegacyColor::Hsla { hue: hue + rhs[0], saturation: saturation + rhs[1], lightness: lightness + rhs[2], alpha: alpha + rhs[3], } } - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, alpha, } => { let rhs = rhs.as_lcha_f32(); - Color::Lcha { + LegacyColor::Lcha { lightness: lightness + rhs[0], chroma: chroma + rhs[1], hue: hue + rhs[2], @@ -1345,9 +1345,9 @@ impl Add for Color { } } -impl From for wgpu::Color { - fn from(color: Color) -> Self { - if let Color::RgbaLinear { +impl From for wgpu::Color { + fn from(color: LegacyColor) -> Self { + if let LegacyColor::RgbaLinear { red, green, blue, @@ -1366,50 +1366,50 @@ impl From for wgpu::Color { } } -impl Mul for Color { - type Output = Color; +impl Mul for LegacyColor { + type Output = LegacyColor; fn mul(self, rhs: f32) -> Self::Output { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, alpha, - } => Color::Rgba { + } => LegacyColor::Rgba { red: red * rhs, green: green * rhs, blue: blue * rhs, alpha, }, - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, alpha, - } => Color::RgbaLinear { + } => LegacyColor::RgbaLinear { red: red * rhs, green: green * rhs, blue: blue * rhs, alpha, }, - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, alpha, - } => Color::Hsla { + } => LegacyColor::Hsla { hue: hue * rhs, saturation: saturation * rhs, lightness: lightness * rhs, alpha, }, - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, alpha, - } => Color::Lcha { + } => LegacyColor::Lcha { lightness: lightness * rhs, chroma: chroma * rhs, hue: hue * rhs, @@ -1419,20 +1419,20 @@ impl Mul for Color { } } -impl MulAssign for Color { +impl MulAssign for LegacyColor { fn mul_assign(&mut self, rhs: f32) { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, .. } - | Color::RgbaLinear { + | LegacyColor::RgbaLinear { red, green, blue, .. } => { *red *= rhs; *green *= rhs; *blue *= rhs; } - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -1442,7 +1442,7 @@ impl MulAssign for Color { *saturation *= rhs; *lightness *= rhs; } - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -1456,50 +1456,50 @@ impl MulAssign for Color { } } -impl Mul for Color { - type Output = Color; +impl Mul for LegacyColor { + type Output = LegacyColor; fn mul(self, rhs: Vec4) -> Self::Output { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, alpha, - } => Color::Rgba { + } => LegacyColor::Rgba { red: red * rhs.x, green: green * rhs.y, blue: blue * rhs.z, alpha: alpha * rhs.w, }, - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, alpha, - } => Color::RgbaLinear { + } => LegacyColor::RgbaLinear { red: red * rhs.x, green: green * rhs.y, blue: blue * rhs.z, alpha: alpha * rhs.w, }, - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, alpha, - } => Color::Hsla { + } => LegacyColor::Hsla { hue: hue * rhs.x, saturation: saturation * rhs.y, lightness: lightness * rhs.z, alpha: alpha * rhs.w, }, - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, alpha, - } => Color::Lcha { + } => LegacyColor::Lcha { lightness: lightness * rhs.x, chroma: chroma * rhs.y, hue: hue * rhs.z, @@ -1509,16 +1509,16 @@ impl Mul for Color { } } -impl MulAssign for Color { +impl MulAssign for LegacyColor { fn mul_assign(&mut self, rhs: Vec4) { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, alpha, } - | Color::RgbaLinear { + | LegacyColor::RgbaLinear { red, green, blue, @@ -1529,7 +1529,7 @@ impl MulAssign for Color { *blue *= rhs.z; *alpha *= rhs.w; } - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -1540,7 +1540,7 @@ impl MulAssign for Color { *lightness *= rhs.z; *alpha *= rhs.w; } - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -1555,50 +1555,50 @@ impl MulAssign for Color { } } -impl Mul for Color { - type Output = Color; +impl Mul for LegacyColor { + type Output = LegacyColor; fn mul(self, rhs: Vec3) -> Self::Output { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, alpha, - } => Color::Rgba { + } => LegacyColor::Rgba { red: red * rhs.x, green: green * rhs.y, blue: blue * rhs.z, alpha, }, - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, alpha, - } => Color::RgbaLinear { + } => LegacyColor::RgbaLinear { red: red * rhs.x, green: green * rhs.y, blue: blue * rhs.z, alpha, }, - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, alpha, - } => Color::Hsla { + } => LegacyColor::Hsla { hue: hue * rhs.x, saturation: saturation * rhs.y, lightness: lightness * rhs.z, alpha, }, - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, alpha, - } => Color::Lcha { + } => LegacyColor::Lcha { lightness: lightness * rhs.x, chroma: chroma * rhs.y, hue: hue * rhs.z, @@ -1608,20 +1608,20 @@ impl Mul for Color { } } -impl MulAssign for Color { +impl MulAssign for LegacyColor { fn mul_assign(&mut self, rhs: Vec3) { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, .. } - | Color::RgbaLinear { + | LegacyColor::RgbaLinear { red, green, blue, .. } => { *red *= rhs.x; *green *= rhs.y; *blue *= rhs.z; } - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -1631,7 +1631,7 @@ impl MulAssign for Color { *saturation *= rhs.y; *lightness *= rhs.z; } - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -1645,50 +1645,50 @@ impl MulAssign for Color { } } -impl Mul<[f32; 4]> for Color { - type Output = Color; +impl Mul<[f32; 4]> for LegacyColor { + type Output = LegacyColor; fn mul(self, rhs: [f32; 4]) -> Self::Output { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, alpha, - } => Color::Rgba { + } => LegacyColor::Rgba { red: red * rhs[0], green: green * rhs[1], blue: blue * rhs[2], alpha: alpha * rhs[3], }, - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, alpha, - } => Color::RgbaLinear { + } => LegacyColor::RgbaLinear { red: red * rhs[0], green: green * rhs[1], blue: blue * rhs[2], alpha: alpha * rhs[3], }, - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, alpha, - } => Color::Hsla { + } => LegacyColor::Hsla { hue: hue * rhs[0], saturation: saturation * rhs[1], lightness: lightness * rhs[2], alpha: alpha * rhs[3], }, - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, alpha, - } => Color::Lcha { + } => LegacyColor::Lcha { lightness: lightness * rhs[0], chroma: chroma * rhs[1], hue: hue * rhs[2], @@ -1698,16 +1698,16 @@ impl Mul<[f32; 4]> for Color { } } -impl MulAssign<[f32; 4]> for Color { +impl MulAssign<[f32; 4]> for LegacyColor { fn mul_assign(&mut self, rhs: [f32; 4]) { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, alpha, } - | Color::RgbaLinear { + | LegacyColor::RgbaLinear { red, green, blue, @@ -1718,7 +1718,7 @@ impl MulAssign<[f32; 4]> for Color { *blue *= rhs[2]; *alpha *= rhs[3]; } - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -1729,7 +1729,7 @@ impl MulAssign<[f32; 4]> for Color { *lightness *= rhs[2]; *alpha *= rhs[3]; } - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -1744,50 +1744,50 @@ impl MulAssign<[f32; 4]> for Color { } } -impl Mul<[f32; 3]> for Color { - type Output = Color; +impl Mul<[f32; 3]> for LegacyColor { + type Output = LegacyColor; fn mul(self, rhs: [f32; 3]) -> Self::Output { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, alpha, - } => Color::Rgba { + } => LegacyColor::Rgba { red: red * rhs[0], green: green * rhs[1], blue: blue * rhs[2], alpha, }, - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, alpha, - } => Color::RgbaLinear { + } => LegacyColor::RgbaLinear { red: red * rhs[0], green: green * rhs[1], blue: blue * rhs[2], alpha, }, - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, alpha, - } => Color::Hsla { + } => LegacyColor::Hsla { hue: hue * rhs[0], saturation: saturation * rhs[1], lightness: lightness * rhs[2], alpha, }, - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, alpha, - } => Color::Lcha { + } => LegacyColor::Lcha { lightness: lightness * rhs[0], chroma: chroma * rhs[1], hue: hue * rhs[2], @@ -1797,20 +1797,20 @@ impl Mul<[f32; 3]> for Color { } } -impl MulAssign<[f32; 3]> for Color { +impl MulAssign<[f32; 3]> for LegacyColor { fn mul_assign(&mut self, rhs: [f32; 3]) { match self { - Color::Rgba { + LegacyColor::Rgba { red, green, blue, .. } - | Color::RgbaLinear { + | LegacyColor::RgbaLinear { red, green, blue, .. } => { *red *= rhs[0]; *green *= rhs[1]; *blue *= rhs[2]; } - Color::Hsla { + LegacyColor::Hsla { hue, saturation, lightness, @@ -1820,7 +1820,7 @@ impl MulAssign<[f32; 3]> for Color { *saturation *= rhs[1]; *lightness *= rhs[2]; } - Color::Lcha { + LegacyColor::Lcha { lightness, chroma, hue, @@ -1834,7 +1834,7 @@ impl MulAssign<[f32; 3]> for Color { } } -impl encase::ShaderType for Color { +impl encase::ShaderType for LegacyColor { type ExtraMetadata = (); const METADATA: encase::private::Metadata = { @@ -1854,7 +1854,7 @@ impl encase::ShaderType for Color { const UNIFORM_COMPAT_ASSERT: fn() = || {}; } -impl encase::private::WriteInto for Color { +impl encase::private::WriteInto for LegacyColor { fn write_into(&self, writer: &mut encase::private::Writer) { let linear = self.as_linear_rgba_f32(); for el in &linear { @@ -1863,7 +1863,7 @@ impl encase::private::WriteInto for Color { } } -impl encase::private::ReadFrom for Color { +impl encase::private::ReadFrom for LegacyColor { fn read_from( &mut self, reader: &mut encase::private::Reader, @@ -1873,7 +1873,7 @@ impl encase::private::ReadFrom for Color { encase::private::ReadFrom::read_from(el, reader); } - *self = Color::RgbaLinear { + *self = LegacyColor::RgbaLinear { red: buffer[0], green: buffer[1], blue: buffer[2], @@ -1882,7 +1882,7 @@ impl encase::private::ReadFrom for Color { } } -impl encase::private::CreateFrom for Color { +impl encase::private::CreateFrom for LegacyColor { fn create_from(reader: &mut encase::private::Reader) -> Self where B: encase::private::BufferRef, @@ -1893,7 +1893,7 @@ impl encase::private::CreateFrom for Color { let green: f32 = encase::private::CreateFrom::create_from(reader); let blue: f32 = encase::private::CreateFrom::create_from(reader); let alpha: f32 = encase::private::CreateFrom::create_from(reader); - Color::RgbaLinear { + LegacyColor::RgbaLinear { red, green, blue, @@ -1902,7 +1902,7 @@ impl encase::private::CreateFrom for Color { } } -impl encase::ShaderSize for Color {} +impl encase::ShaderSize for LegacyColor {} #[derive(Debug, Error, PartialEq, Eq)] pub enum HexColorError { @@ -1956,27 +1956,36 @@ mod tests { #[test] fn hex_color() { - assert_eq!(Color::hex("FFF"), Ok(Color::WHITE)); - assert_eq!(Color::hex("FFFF"), Ok(Color::WHITE)); - assert_eq!(Color::hex("FFFFFF"), Ok(Color::WHITE)); - assert_eq!(Color::hex("FFFFFFFF"), Ok(Color::WHITE)); - assert_eq!(Color::hex("000"), Ok(Color::BLACK)); - assert_eq!(Color::hex("000F"), Ok(Color::BLACK)); - assert_eq!(Color::hex("000000"), Ok(Color::BLACK)); - assert_eq!(Color::hex("000000FF"), Ok(Color::BLACK)); - assert_eq!(Color::hex("03a9f4"), Ok(Color::rgb_u8(3, 169, 244))); - assert_eq!(Color::hex("yy"), Err(HexColorError::Length)); - assert_eq!(Color::hex("yyy"), Err(HexColorError::Char('y'))); - assert_eq!(Color::hex("#f2a"), Ok(Color::rgb_u8(255, 34, 170))); - assert_eq!(Color::hex("#e23030"), Ok(Color::rgb_u8(226, 48, 48))); - assert_eq!(Color::hex("#ff"), Err(HexColorError::Length)); - assert_eq!(Color::hex("##fff"), Err(HexColorError::Char('#'))); + assert_eq!(LegacyColor::hex("FFF"), Ok(LegacyColor::WHITE)); + assert_eq!(LegacyColor::hex("FFFF"), Ok(LegacyColor::WHITE)); + assert_eq!(LegacyColor::hex("FFFFFF"), Ok(LegacyColor::WHITE)); + assert_eq!(LegacyColor::hex("FFFFFFFF"), Ok(LegacyColor::WHITE)); + assert_eq!(LegacyColor::hex("000"), Ok(LegacyColor::BLACK)); + assert_eq!(LegacyColor::hex("000F"), Ok(LegacyColor::BLACK)); + assert_eq!(LegacyColor::hex("000000"), Ok(LegacyColor::BLACK)); + assert_eq!(LegacyColor::hex("000000FF"), Ok(LegacyColor::BLACK)); + assert_eq!( + LegacyColor::hex("03a9f4"), + Ok(LegacyColor::rgb_u8(3, 169, 244)) + ); + assert_eq!(LegacyColor::hex("yy"), Err(HexColorError::Length)); + assert_eq!(LegacyColor::hex("yyy"), Err(HexColorError::Char('y'))); + assert_eq!( + LegacyColor::hex("#f2a"), + Ok(LegacyColor::rgb_u8(255, 34, 170)) + ); + assert_eq!( + LegacyColor::hex("#e23030"), + Ok(LegacyColor::rgb_u8(226, 48, 48)) + ); + assert_eq!(LegacyColor::hex("#ff"), Err(HexColorError::Length)); + assert_eq!(LegacyColor::hex("##fff"), Err(HexColorError::Char('#'))); } #[test] fn conversions_vec4() { let starting_vec4 = Vec4::new(0.4, 0.5, 0.6, 1.0); - let starting_color = Color::rgba_from_array(starting_vec4); + let starting_color = LegacyColor::rgba_from_array(starting_vec4); assert_eq!(starting_vec4, starting_color.rgba_to_vec4()); @@ -1984,18 +1993,18 @@ mod tests { assert_eq!( starting_color * transformation, - Color::rgba_from_array(starting_vec4 * transformation) + LegacyColor::rgba_from_array(starting_vec4 * transformation) ); } #[test] fn mul_and_mulassign_f32() { let transformation = 0.5; - let starting_color = Color::rgba(0.4, 0.5, 0.6, 1.0); + let starting_color = LegacyColor::rgba(0.4, 0.5, 0.6, 1.0); assert_eq!( starting_color * transformation, - Color::rgba(0.4 * 0.5, 0.5 * 0.5, 0.6 * 0.5, 1.0), + LegacyColor::rgba(0.4 * 0.5, 0.5 * 0.5, 0.6 * 0.5, 1.0), ); let mut mutated_color = starting_color; @@ -2007,11 +2016,11 @@ mod tests { #[test] fn mul_and_mulassign_f32by3() { let transformation = [0.4, 0.5, 0.6]; - let starting_color = Color::rgba(0.4, 0.5, 0.6, 1.0); + let starting_color = LegacyColor::rgba(0.4, 0.5, 0.6, 1.0); assert_eq!( starting_color * transformation, - Color::rgba(0.4 * 0.4, 0.5 * 0.5, 0.6 * 0.6, 1.0), + LegacyColor::rgba(0.4 * 0.4, 0.5 * 0.5, 0.6 * 0.6, 1.0), ); let mut mutated_color = starting_color; @@ -2023,11 +2032,11 @@ mod tests { #[test] fn mul_and_mulassign_f32by4() { let transformation = [0.4, 0.5, 0.6, 0.9]; - let starting_color = Color::rgba(0.4, 0.5, 0.6, 1.0); + let starting_color = LegacyColor::rgba(0.4, 0.5, 0.6, 1.0); assert_eq!( starting_color * transformation, - Color::rgba(0.4 * 0.4, 0.5 * 0.5, 0.6 * 0.6, 1.0 * 0.9), + LegacyColor::rgba(0.4 * 0.4, 0.5 * 0.5, 0.6 * 0.6, 1.0 * 0.9), ); let mut mutated_color = starting_color; @@ -2039,11 +2048,11 @@ mod tests { #[test] fn mul_and_mulassign_vec3() { let transformation = Vec3::new(0.2, 0.3, 0.4); - let starting_color = Color::rgba(0.4, 0.5, 0.6, 1.0); + let starting_color = LegacyColor::rgba(0.4, 0.5, 0.6, 1.0); assert_eq!( starting_color * transformation, - Color::rgba(0.4 * 0.2, 0.5 * 0.3, 0.6 * 0.4, 1.0), + LegacyColor::rgba(0.4 * 0.2, 0.5 * 0.3, 0.6 * 0.4, 1.0), ); let mut mutated_color = starting_color; @@ -2055,11 +2064,11 @@ mod tests { #[test] fn mul_and_mulassign_vec4() { let transformation = Vec4::new(0.2, 0.3, 0.4, 0.5); - let starting_color = Color::rgba(0.4, 0.5, 0.6, 1.0); + let starting_color = LegacyColor::rgba(0.4, 0.5, 0.6, 1.0); assert_eq!( starting_color * transformation, - Color::rgba(0.4 * 0.2, 0.5 * 0.3, 0.6 * 0.4, 1.0 * 0.5), + LegacyColor::rgba(0.4 * 0.2, 0.5 * 0.3, 0.6 * 0.4, 1.0 * 0.5), ); let mut mutated_color = starting_color; @@ -2071,18 +2080,18 @@ mod tests { // regression test for https://github.com/bevyengine/bevy/pull/8040 #[test] fn convert_to_rgba_linear() { - let rgba = Color::rgba(0., 0., 0., 0.); - let rgba_l = Color::rgba_linear(0., 0., 0., 0.); - let hsla = Color::hsla(0., 0., 0., 0.); - let lcha = Color::lcha(0., 0., 0., 0.); + let rgba = LegacyColor::rgba(0., 0., 0., 0.); + let rgba_l = LegacyColor::rgba_linear(0., 0., 0., 0.); + let hsla = LegacyColor::hsla(0., 0., 0., 0.); + let lcha = LegacyColor::lcha(0., 0., 0., 0.); assert_eq!(rgba_l, rgba_l.as_rgba_linear()); - let Color::RgbaLinear { .. } = rgba.as_rgba_linear() else { + let LegacyColor::RgbaLinear { .. } = rgba.as_rgba_linear() else { panic!("from Rgba") }; - let Color::RgbaLinear { .. } = hsla.as_rgba_linear() else { + let LegacyColor::RgbaLinear { .. } = hsla.as_rgba_linear() else { panic!("from Hsla") }; - let Color::RgbaLinear { .. } = lcha.as_rgba_linear() else { + let LegacyColor::RgbaLinear { .. } = lcha.as_rgba_linear() else { panic!("from Lcha") }; } diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 22a4efee7237d5..c9d99f661ce026 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -38,7 +38,7 @@ pub mod prelude { Camera, ClearColor, ClearColorConfig, OrthographicProjection, PerspectiveProjection, Projection, }, - color::Color, + color::LegacyColor, mesh::{morph::MorphWeights, primitives::Meshable, Mesh}, render_resource::Shader, spatial_bundle::SpatialBundle, @@ -330,7 +330,7 @@ impl Plugin for RenderPlugin { )); app.register_type::() - .register_type::() + .register_type::() .register_type::() .register_type::() .register_type::() diff --git a/crates/bevy_render/src/render_phase/draw_state.rs b/crates/bevy_render/src/render_phase/draw_state.rs index 0468754af62ee2..62f668ce951ce9 100644 --- a/crates/bevy_render/src/render_phase/draw_state.rs +++ b/crates/bevy_render/src/render_phase/draw_state.rs @@ -1,6 +1,6 @@ use crate::{ camera::Viewport, - prelude::Color, + prelude::LegacyColor, render_resource::{ BindGroup, BindGroupId, Buffer, BufferId, BufferSlice, RenderPipeline, RenderPipelineId, ShaderStages, @@ -598,7 +598,7 @@ impl<'a> TrackedRenderPass<'a> { /// Sets the blend color as used by some of the blending modes. /// /// Subsequent blending tests will test against this value. - pub fn set_blend_constant(&mut self, color: Color) { + pub fn set_blend_constant(&mut self, color: LegacyColor) { detailed_trace!("set blend constant: {:?}", color); self.pass.set_blend_constant(wgpu::Color::from(color)); } diff --git a/crates/bevy_render/src/render_resource/bind_group.rs b/crates/bevy_render/src/render_resource/bind_group.rs index 03e98abbd8818a..fc7661b1751965 100644 --- a/crates/bevy_render/src/render_resource/bind_group.rs +++ b/crates/bevy_render/src/render_resource/bind_group.rs @@ -74,12 +74,12 @@ impl Deref for BindGroup { /// what their binding type is, and what index they should be bound at: /// /// ``` -/// # use bevy_render::{color::Color, render_resource::*, texture::Image}; +/// # use bevy_render::{color::LegacyColor, render_resource::*, texture::Image}; /// # use bevy_asset::Handle; /// #[derive(AsBindGroup)] /// struct CoolMaterial { /// #[uniform(0)] -/// color: Color, +/// color: LegacyColor, /// #[texture(1)] /// #[sampler(2)] /// color_texture: Handle, @@ -109,7 +109,7 @@ impl Deref for BindGroup { /// * `uniform(BINDING_INDEX)` /// * The field will be converted to a shader-compatible type using the [`ShaderType`] trait, written to a [`Buffer`], and bound as a uniform. /// [`ShaderType`] is implemented for most math types already, such as [`f32`], [`Vec4`](bevy_math::Vec4), and -/// [`Color`](crate::color::Color). It can also be derived for custom structs. +/// [`LegacyColor`](crate::color::LegacyColor). It can also be derived for custom structs. /// /// * `texture(BINDING_INDEX, arguments)` /// * This field's [`Handle`](bevy_asset::Handle) will be used to look up the matching [`Texture`](crate::render_resource::Texture) @@ -162,24 +162,24 @@ impl Deref for BindGroup { /// /// Note that fields without field-level binding attributes will be ignored. /// ``` -/// # use bevy_render::{color::Color, render_resource::AsBindGroup}; +/// # use bevy_render::{color::LegacyColor, render_resource::AsBindGroup}; /// # use bevy_asset::Handle; /// #[derive(AsBindGroup)] /// struct CoolMaterial { /// #[uniform(0)] -/// color: Color, +/// color: LegacyColor, /// this_field_is_ignored: String, /// } /// ``` /// /// As mentioned above, [`Option>`] is also supported: /// ``` -/// # use bevy_render::{color::Color, render_resource::AsBindGroup, texture::Image}; +/// # use bevy_render::{color::LegacyColor, render_resource::AsBindGroup, texture::Image}; /// # use bevy_asset::Handle; /// #[derive(AsBindGroup)] /// struct CoolMaterial { /// #[uniform(0)] -/// color: Color, +/// color: LegacyColor, /// #[texture(1)] /// #[sampler(2)] /// color_texture: Option>, @@ -190,11 +190,11 @@ impl Deref for BindGroup { /// /// Field uniforms with the same index will be combined into a single binding: /// ``` -/// # use bevy_render::{color::Color, render_resource::AsBindGroup}; +/// # use bevy_render::{color::LegacyColor, render_resource::AsBindGroup}; /// #[derive(AsBindGroup)] /// struct CoolMaterial { /// #[uniform(0)] -/// color: Color, +/// color: LegacyColor, /// #[uniform(0)] /// roughness: f32, /// } @@ -227,17 +227,17 @@ impl Deref for BindGroup { /// The previous `CoolMaterial` example illustrating "combining multiple field-level uniform attributes with the same binding index" can /// also be equivalently represented with a single struct-level uniform attribute: /// ``` -/// # use bevy_render::{color::Color, render_resource::{AsBindGroup, ShaderType}}; +/// # use bevy_render::{color::LegacyColor, render_resource::{AsBindGroup, ShaderType}}; /// #[derive(AsBindGroup)] /// #[uniform(0, CoolMaterialUniform)] /// struct CoolMaterial { -/// color: Color, +/// color: LegacyColor, /// roughness: f32, /// } /// /// #[derive(ShaderType)] /// struct CoolMaterialUniform { -/// color: Color, +/// color: LegacyColor, /// roughness: f32, /// } /// @@ -253,12 +253,12 @@ impl Deref for BindGroup { /// /// Setting `bind_group_data` looks like this: /// ``` -/// # use bevy_render::{color::Color, render_resource::AsBindGroup}; +/// # use bevy_render::{color::LegacyColor, render_resource::AsBindGroup}; /// #[derive(AsBindGroup)] /// #[bind_group_data(CoolMaterialKey)] /// struct CoolMaterial { /// #[uniform(0)] -/// color: Color, +/// color: LegacyColor, /// is_shaded: bool, /// } /// diff --git a/crates/bevy_render/src/texture/texture_attachment.rs b/crates/bevy_render/src/texture/texture_attachment.rs index c8bc27153e92b2..425b12146c97a9 100644 --- a/crates/bevy_render/src/texture/texture_attachment.rs +++ b/crates/bevy_render/src/texture/texture_attachment.rs @@ -1,5 +1,5 @@ use super::CachedTexture; -use crate::{prelude::Color, render_resource::TextureView}; +use crate::{prelude::LegacyColor, render_resource::TextureView}; use std::sync::{ atomic::{AtomicBool, Ordering}, Arc, @@ -13,7 +13,7 @@ use wgpu::{ pub struct ColorAttachment { pub texture: CachedTexture, pub resolve_target: Option, - clear_color: Option, + clear_color: Option, is_first_call: Arc, } @@ -21,7 +21,7 @@ impl ColorAttachment { pub fn new( texture: CachedTexture, resolve_target: Option, - clear_color: Option, + clear_color: Option, ) -> Self { Self { texture, diff --git a/crates/bevy_sprite/src/mesh2d/color_material.rs b/crates/bevy_sprite/src/mesh2d/color_material.rs index cbf6baf0823175..899adf25601739 100644 --- a/crates/bevy_sprite/src/mesh2d/color_material.rs +++ b/crates/bevy_sprite/src/mesh2d/color_material.rs @@ -4,7 +4,8 @@ use bevy_asset::{load_internal_asset, Asset, AssetApp, Assets, Handle}; use bevy_math::Vec4; use bevy_reflect::prelude::*; use bevy_render::{ - color::Color, prelude::Shader, render_asset::RenderAssets, render_resource::*, texture::Image, + color::LegacyColor, prelude::Shader, render_asset::RenderAssets, render_resource::*, + texture::Image, }; pub const COLOR_MATERIAL_SHADER_HANDLE: Handle = @@ -28,7 +29,7 @@ impl Plugin for ColorMaterialPlugin { app.world.resource_mut::>().insert( Handle::::default(), ColorMaterial { - color: Color::rgb(1.0, 0.0, 1.0), + color: LegacyColor::rgb(1.0, 0.0, 1.0), ..Default::default() }, ); @@ -40,7 +41,7 @@ impl Plugin for ColorMaterialPlugin { #[reflect(Default, Debug)] #[uniform(0, ColorMaterialUniform)] pub struct ColorMaterial { - pub color: Color, + pub color: LegacyColor, #[texture(1)] #[sampler(2)] pub texture: Option>, @@ -49,14 +50,14 @@ pub struct ColorMaterial { impl Default for ColorMaterial { fn default() -> Self { ColorMaterial { - color: Color::WHITE, + color: LegacyColor::WHITE, texture: None, } } } -impl From for ColorMaterial { - fn from(color: Color) -> Self { +impl From for ColorMaterial { + fn from(color: LegacyColor) -> Self { ColorMaterial { color, ..Default::default() diff --git a/crates/bevy_sprite/src/mesh2d/material.rs b/crates/bevy_sprite/src/mesh2d/material.rs index 0a6da78be7eccc..9858204a3402a4 100644 --- a/crates/bevy_sprite/src/mesh2d/material.rs +++ b/crates/bevy_sprite/src/mesh2d/material.rs @@ -54,7 +54,7 @@ use crate::{ /// # use bevy_sprite::{Material2d, MaterialMesh2dBundle}; /// # use bevy_ecs::prelude::*; /// # use bevy_reflect::TypePath; -/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::Color}; +/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::LegacyColor}; /// # use bevy_asset::{Handle, AssetServer, Assets, Asset}; /// /// #[derive(AsBindGroup, Debug, Clone, Asset, TypePath)] @@ -62,7 +62,7 @@ use crate::{ /// // Uniform bindings must implement `ShaderType`, which will be used to convert the value to /// // its shader-compatible equivalent. Most core math types already implement `ShaderType`. /// #[uniform(0)] -/// color: Color, +/// color: LegacyColor, /// // Images can be bound as textures in shaders. If the Image's sampler is also needed, just /// // add the sampler attribute with a different binding index. /// #[texture(1)] @@ -82,7 +82,7 @@ use crate::{ /// fn setup(mut commands: Commands, mut materials: ResMut>, asset_server: Res) { /// commands.spawn(MaterialMesh2dBundle { /// material: materials.add(CustomMaterial { -/// color: Color::RED, +/// color: LegacyColor::RED, /// color_texture: asset_server.load("some_image.png"), /// }), /// ..Default::default() diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index cb05f7c03cbdd1..f9987124518811 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -16,7 +16,7 @@ use bevy_ecs::{ }; use bevy_math::{Affine3A, Quat, Rect, Vec2, Vec4}; use bevy_render::{ - color::Color, + color::LegacyColor, render_asset::RenderAssets, render_phase::{ DrawFunctions, PhaseItem, RenderCommand, RenderCommandResult, RenderPhase, SetItemPipeline, @@ -295,7 +295,7 @@ impl SpecializedRenderPipeline for SpritePipeline { pub struct ExtractedSprite { pub transform: GlobalTransform, - pub color: Color, + pub color: LegacyColor, /// Select an area of the texture pub rect: Option, /// Change the on-screen size of the sprite @@ -406,7 +406,7 @@ struct SpriteInstance { impl SpriteInstance { #[inline] - fn from(transform: &Affine3A, color: &Color, uv_offset_scale: &Vec4) -> Self { + fn from(transform: &Affine3A, color: &LegacyColor, uv_offset_scale: &Vec4) -> Self { let transpose_model_3x3 = transform.matrix3.transpose(); Self { i_model_transpose: [ @@ -524,7 +524,7 @@ pub fn queue_sprites( let sort_key = FloatOrd(extracted_sprite.transform.translation().z); // Add the item to the render phase - if extracted_sprite.color != Color::WHITE { + if extracted_sprite.color != LegacyColor::WHITE { transparent_phase.add(Transparent2d { draw_function: draw_sprite_function, pipeline: colored_pipeline, diff --git a/crates/bevy_sprite/src/sprite.rs b/crates/bevy_sprite/src/sprite.rs index 1cd3cf73d5dbed..62249606511693 100644 --- a/crates/bevy_sprite/src/sprite.rs +++ b/crates/bevy_sprite/src/sprite.rs @@ -1,7 +1,7 @@ use bevy_ecs::{component::Component, reflect::ReflectComponent}; use bevy_math::{Rect, Vec2}; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; -use bevy_render::color::Color; +use bevy_render::color::LegacyColor; use crate::TextureSlicer; @@ -13,7 +13,7 @@ use crate::TextureSlicer; #[repr(C)] pub struct Sprite { /// The sprite's color tint - pub color: Color, + pub color: LegacyColor, /// Flip the sprite along the `X` axis pub flip_x: bool, /// Flip the sprite along the `Y` axis diff --git a/crates/bevy_text/src/text.rs b/crates/bevy_text/src/text.rs index 74397e000be674..5114115cf356d4 100644 --- a/crates/bevy_text/src/text.rs +++ b/crates/bevy_text/src/text.rs @@ -1,7 +1,7 @@ use bevy_asset::Handle; use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; use bevy_reflect::prelude::*; -use bevy_render::color::Color; +use bevy_render::color::LegacyColor; use bevy_utils::default; use serde::{Deserialize, Serialize}; @@ -33,7 +33,7 @@ impl Text { /// /// ``` /// # use bevy_asset::Handle; - /// # use bevy_render::color::Color; + /// # use bevy_render::color::LegacyColor; /// # use bevy_text::{Font, Text, TextStyle, JustifyText}; /// # /// # let font_handle: Handle = Default::default(); @@ -45,7 +45,7 @@ impl Text { /// TextStyle { /// font: font_handle.clone(), /// font_size: 60.0, - /// color: Color::WHITE, + /// color: LegacyColor::WHITE, /// }, /// ); /// @@ -54,7 +54,7 @@ impl Text { /// TextStyle { /// font: font_handle, /// font_size: 60.0, - /// color: Color::WHITE, + /// color: LegacyColor::WHITE, /// }, /// ) // You can still add text justifaction. /// .with_justify(JustifyText::Center); @@ -70,7 +70,7 @@ impl Text { /// /// ``` /// # use bevy_asset::Handle; - /// # use bevy_render::color::Color; + /// # use bevy_render::color::LegacyColor; /// # use bevy_text::{Font, Text, TextStyle, TextSection}; /// # /// # let font_handle: Handle = Default::default(); @@ -81,7 +81,7 @@ impl Text { /// TextStyle { /// font: font_handle.clone(), /// font_size: 60.0, - /// color: Color::BLUE, + /// color: LegacyColor::BLUE, /// }, /// ), /// TextSection::new( @@ -89,7 +89,7 @@ impl Text { /// TextStyle { /// font: font_handle, /// font_size: 60.0, - /// color: Color::RED, + /// color: LegacyColor::RED, /// }, /// ), /// ]); @@ -204,7 +204,7 @@ pub struct TextStyle { /// A new font atlas is generated for every combination of font handle and scaled font size /// which can have a strong performance impact. pub font_size: f32, - pub color: Color, + pub color: LegacyColor, } impl Default for TextStyle { @@ -212,7 +212,7 @@ impl Default for TextStyle { Self { font: Default::default(), font_size: 12.0, - color: Color::WHITE, + color: LegacyColor::WHITE, } } } diff --git a/crates/bevy_text/src/text2d.rs b/crates/bevy_text/src/text2d.rs index d12198e1469bcd..ef130ed4d57732 100644 --- a/crates/bevy_text/src/text2d.rs +++ b/crates/bevy_text/src/text2d.rs @@ -16,7 +16,7 @@ use bevy_ecs::{ use bevy_math::Vec2; use bevy_reflect::Reflect; use bevy_render::{ - prelude::Color, + prelude::LegacyColor, texture::Image, view::{InheritedVisibility, ViewVisibility, Visibility}, Extract, @@ -115,7 +115,7 @@ pub fn extract_text2d_sprite( let transform = *global_transform * GlobalTransform::from_translation(alignment_translation.extend(0.)) * scaling; - let mut color = Color::WHITE; + let mut color = LegacyColor::WHITE; let mut current_section = usize::MAX; for PositionedGlyph { position, diff --git a/crates/bevy_ui/src/node_bundles.rs b/crates/bevy_ui/src/node_bundles.rs index 964fd61c514ca0..19845002e3d49e 100644 --- a/crates/bevy_ui/src/node_bundles.rs +++ b/crates/bevy_ui/src/node_bundles.rs @@ -10,7 +10,7 @@ use crate::{ use bevy_asset::Handle; use bevy_ecs::bundle::Bundle; use bevy_render::{ - prelude::Color, + prelude::LegacyColor, view::{InheritedVisibility, ViewVisibility, Visibility}, }; use bevy_sprite::TextureAtlas; @@ -60,8 +60,8 @@ impl Default for NodeBundle { fn default() -> Self { NodeBundle { // Transparent background - background_color: Color::NONE.into(), - border_color: Color::NONE.into(), + background_color: LegacyColor::NONE.into(), + border_color: LegacyColor::NONE.into(), node: Default::default(), style: Default::default(), focus_policy: Default::default(), @@ -227,7 +227,7 @@ impl Default for TextBundle { view_visibility: Default::default(), z_index: Default::default(), // Transparent background - background_color: BackgroundColor(Color::NONE), + background_color: BackgroundColor(LegacyColor::NONE), } } } @@ -267,7 +267,7 @@ impl TextBundle { } /// Returns this [`TextBundle`] with a new [`BackgroundColor`]. - pub const fn with_background_color(mut self, color: Color) -> Self { + pub const fn with_background_color(mut self, color: LegacyColor) -> Self { self.background_color = BackgroundColor(color); self } @@ -343,7 +343,7 @@ impl Default for ButtonBundle { node: Default::default(), button: Default::default(), style: Default::default(), - border_color: BorderColor(Color::NONE), + border_color: BorderColor(LegacyColor::NONE), interaction: Default::default(), background_color: Default::default(), image: Default::default(), diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index 8ff453b7404d69..a82d3edc4ecbf5 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -28,7 +28,7 @@ use bevy_ecs::prelude::*; use bevy_math::{Mat4, Rect, URect, UVec4, Vec2, Vec3, Vec4Swizzles}; use bevy_render::{ camera::Camera, - color::Color, + color::LegacyColor, render_asset::RenderAssets, render_graph::{RenderGraph, RunGraphOnViewNode}, render_phase::{sort_phase_system, AddRenderCommand, DrawFunctions, RenderPhase}, @@ -133,7 +133,7 @@ fn get_ui_graph(render_app: &mut App) -> RenderGraph { pub struct ExtractedUiNode { pub stack_index: u32, pub transform: Mat4, - pub color: Color, + pub color: LegacyColor, pub rect: Rect, pub image: AssetId, pub atlas_size: Option, @@ -601,7 +601,7 @@ pub fn extract_text_uinodes( let transform = Mat4::from(global_transform.affine()) * Mat4::from_translation(logical_top_left_nearest_pixel.extend(0.)); - let mut color = Color::WHITE; + let mut color = LegacyColor::WHITE; let mut current_section = usize::MAX; for PositionedGlyph { position, diff --git a/crates/bevy_ui/src/ui_material.rs b/crates/bevy_ui/src/ui_material.rs index 7f5cd0923a5a6e..7f2ce039621a4e 100644 --- a/crates/bevy_ui/src/ui_material.rs +++ b/crates/bevy_ui/src/ui_material.rs @@ -24,7 +24,7 @@ use bevy_render::render_resource::{AsBindGroup, RenderPipelineDescriptor, Shader /// # use bevy_ui::prelude::*; /// # use bevy_ecs::prelude::*; /// # use bevy_reflect::TypePath; -/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::Color}; +/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::LegacyColor}; /// # use bevy_asset::{Handle, AssetServer, Assets, Asset}; /// /// #[derive(AsBindGroup, Asset, TypePath, Debug, Clone)] @@ -32,7 +32,7 @@ use bevy_render::render_resource::{AsBindGroup, RenderPipelineDescriptor, Shader /// // Uniform bindings must implement `ShaderType`, which will be used to convert the value to /// // its shader-compatible equivalent. Most core math types already implement `ShaderType`. /// #[uniform(0)] -/// color: Color, +/// color: LegacyColor, /// // Images can be bound as textures in shaders. If the Image's sampler is also needed, just /// // add the sampler attribute with a different binding index. /// #[texture(1)] @@ -56,7 +56,7 @@ use bevy_render::render_resource::{AsBindGroup, RenderPipelineDescriptor, Shader /// ..Default::default() /// }, /// material: materials.add(CustomMaterial { -/// color: Color::RED, +/// color: LegacyColor::RED, /// color_texture: asset_server.load("some_image.png"), /// }), /// ..Default::default() diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 8e42dead8b1c6d..aef4e724a05b9c 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -5,7 +5,7 @@ use bevy_math::{Rect, Vec2}; use bevy_reflect::prelude::*; use bevy_render::{ camera::{Camera, RenderTarget}, - color::Color, + color::LegacyColor, texture::Image, }; use bevy_transform::prelude::GlobalTransform; @@ -1597,10 +1597,10 @@ pub enum GridPlacementError { derive(serde::Serialize, serde::Deserialize), reflect(Serialize, Deserialize) )] -pub struct BackgroundColor(pub Color); +pub struct BackgroundColor(pub LegacyColor); impl BackgroundColor { - pub const DEFAULT: Self = Self(Color::WHITE); + pub const DEFAULT: Self = Self(LegacyColor::WHITE); } impl Default for BackgroundColor { @@ -1609,8 +1609,8 @@ impl Default for BackgroundColor { } } -impl From for BackgroundColor { - fn from(color: Color) -> Self { +impl From for BackgroundColor { + fn from(color: LegacyColor) -> Self { Self(color) } } @@ -1623,16 +1623,16 @@ impl From for BackgroundColor { derive(serde::Serialize, serde::Deserialize), reflect(Serialize, Deserialize) )] -pub struct BorderColor(pub Color); +pub struct BorderColor(pub LegacyColor); -impl From for BorderColor { - fn from(color: Color) -> Self { +impl From for BorderColor { + fn from(color: LegacyColor) -> Self { Self(color) } } impl BorderColor { - pub const DEFAULT: Self = BorderColor(Color::WHITE); + pub const DEFAULT: Self = BorderColor(LegacyColor::WHITE); } impl Default for BorderColor { @@ -1655,7 +1655,7 @@ impl Default for BorderColor { /// ``` /// # use bevy_ecs::prelude::*; /// # use bevy_ui::prelude::*; -/// # use bevy_render::prelude::Color; +/// # use bevy_render::prelude::LegacyColor; /// fn setup_ui(mut commands: Commands) { /// commands.spawn(( /// NodeBundle { @@ -1664,10 +1664,10 @@ impl Default for BorderColor { /// height: Val::Px(100.), /// ..Default::default() /// }, -/// background_color: Color::BLUE.into(), +/// background_color: LegacyColor::BLUE.into(), /// ..Default::default() /// }, -/// Outline::new(Val::Px(10.), Val::ZERO, Color::RED) +/// Outline::new(Val::Px(10.), Val::ZERO, LegacyColor::RED) /// )); /// } /// ``` @@ -1676,7 +1676,7 @@ impl Default for BorderColor { /// ``` /// # use bevy_ecs::prelude::*; /// # use bevy_ui::prelude::*; -/// # use bevy_render::prelude::Color; +/// # use bevy_render::prelude::LegacyColor; /// fn outline_hovered_button_system( /// mut commands: Commands, /// mut node_query: Query<(Entity, &Interaction, Option<&mut Outline>), Changed>, @@ -1684,9 +1684,9 @@ impl Default for BorderColor { /// for (entity, interaction, mut maybe_outline) in node_query.iter_mut() { /// let outline_color = /// if matches!(*interaction, Interaction::Hovered) { -/// Color::WHITE +/// LegacyColor::WHITE /// } else { -/// Color::NONE +/// LegacyColor::NONE /// }; /// if let Some(mut outline) = maybe_outline { /// outline.color = outline_color; @@ -1697,7 +1697,7 @@ impl Default for BorderColor { /// } /// ``` /// Inserting and removing an [`Outline`] component repeatedly will result in table moves, so it is generally preferable to -/// set `Outline::color` to `Color::NONE` to hide an outline. +/// set `Outline::color` to `LegacyColor::NONE` to hide an outline. pub struct Outline { /// The width of the outline. /// @@ -1709,14 +1709,14 @@ pub struct Outline { pub offset: Val, /// The color of the outline. /// - /// If you are frequently toggling outlines for a UI node on and off it is recommended to set `Color::None` to hide the outline. + /// If you are frequently toggling outlines for a UI node on and off it is recommended to set `LegacyColor::NONE` to hide the outline. /// This avoids the table moves that would occur from the repeated insertion and removal of the `Outline` component. - pub color: Color, + pub color: LegacyColor, } impl Outline { /// Create a new outline - pub const fn new(width: Val, offset: Val, color: Color) -> Self { + pub const fn new(width: Val, offset: Val, color: LegacyColor) -> Self { Self { width, offset, diff --git a/errors/B0004.md b/errors/B0004.md index 5cf94109bfa51b..e05d4ef7b8a367 100644 --- a/errors/B0004.md +++ b/errors/B0004.md @@ -34,7 +34,7 @@ fn setup_cube( // cube parent.spawn(PbrBundle { mesh: meshes.add(Cuboid::default()), - material: materials.add(Color::rgb(0.8, 0.7, 0.6)), + material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..default() }); @@ -81,7 +81,7 @@ fn setup_cube( // cube parent.spawn(PbrBundle { mesh: meshes.add(Cuboid::default()), - material: materials.add(Color::rgb(0.8, 0.7, 0.6)), + material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..default() }); diff --git a/examples/2d/2d_shapes.rs b/examples/2d/2d_shapes.rs index be5e70529a8aa7..9d9c463ef83f7a 100644 --- a/examples/2d/2d_shapes.rs +++ b/examples/2d/2d_shapes.rs @@ -37,7 +37,7 @@ fn setup( for (i, shape) in shapes.into_iter().enumerate() { // Distribute colors evenly across the rainbow. - let color = Color::hsl(360. * i as f32 / num_shapes as f32, 0.95, 0.7); + let color = LegacyColor::hsl(360. * i as f32 / num_shapes as f32, 0.95, 0.7); commands.spawn(MaterialMesh2dBundle { mesh: shape, diff --git a/examples/2d/2d_viewport_to_world.rs b/examples/2d/2d_viewport_to_world.rs index 8ed4f881f993f9..59717973ab9754 100644 --- a/examples/2d/2d_viewport_to_world.rs +++ b/examples/2d/2d_viewport_to_world.rs @@ -26,7 +26,7 @@ fn draw_cursor( return; }; - gizmos.circle_2d(point, 10., Color::WHITE); + gizmos.circle_2d(point, 10., LegacyColor::WHITE); } fn setup(mut commands: Commands) { diff --git a/examples/2d/bloom_2d.rs b/examples/2d/bloom_2d.rs index 30e4aa18c7795c..83e90e8d1fbda8 100644 --- a/examples/2d/bloom_2d.rs +++ b/examples/2d/bloom_2d.rs @@ -39,7 +39,7 @@ fn setup( commands.spawn(SpriteBundle { texture: asset_server.load("branding/bevy_bird_dark.png"), sprite: Sprite { - color: Color::rgb(5.0, 5.0, 5.0), // 4. Put something bright in a dark environment to see the effect + color: LegacyColor::rgb(5.0, 5.0, 5.0), // 4. Put something bright in a dark environment to see the effect custom_size: Some(Vec2::splat(160.0)), ..default() }, @@ -50,7 +50,7 @@ fn setup( commands.spawn(MaterialMesh2dBundle { mesh: meshes.add(Circle::new(100.)).into(), // 4. Put something bright in a dark environment to see the effect - material: materials.add(Color::rgb(7.5, 0.0, 7.5)), + material: materials.add(LegacyColor::rgb(7.5, 0.0, 7.5)), transform: Transform::from_translation(Vec3::new(-200., 0., 0.)), ..default() }); @@ -59,7 +59,7 @@ fn setup( commands.spawn(MaterialMesh2dBundle { mesh: meshes.add(RegularPolygon::new(100., 6)).into(), // 4. Put something bright in a dark environment to see the effect - material: materials.add(Color::rgb(6.25, 9.4, 9.1)), + material: materials.add(LegacyColor::rgb(6.25, 9.4, 9.1)), transform: Transform::from_translation(Vec3::new(200., 0., 0.)), ..default() }); @@ -70,7 +70,7 @@ fn setup( "", TextStyle { font_size: 18.0, - color: Color::WHITE, + color: LegacyColor::WHITE, ..default() }, ) diff --git a/examples/2d/bounding_2d.rs b/examples/2d/bounding_2d.rs index ff121d7d8c2585..cc296c0647f1f8 100644 --- a/examples/2d/bounding_2d.rs +++ b/examples/2d/bounding_2d.rs @@ -97,7 +97,7 @@ enum Shape { } fn render_shapes(mut gizmos: Gizmos, query: Query<(&Shape, &Transform)>) { - let color = Color::GRAY; + let color = LegacyColor::GRAY; for (shape, transform) in query.iter() { let translation = transform.translation.xy(); let rotation = transform.rotation.to_euler(EulerRot::YXZ).2; @@ -178,9 +178,9 @@ fn update_volumes( fn render_volumes(mut gizmos: Gizmos, query: Query<(&CurrentVolume, &Intersects)>) { for (volume, intersects) in query.iter() { let color = if **intersects { - Color::CYAN + LegacyColor::CYAN } else { - Color::ORANGE_RED + LegacyColor::ORANGE_RED }; match volume { CurrentVolume::Aabb(a) => { @@ -292,10 +292,10 @@ fn draw_ray(gizmos: &mut Gizmos, ray: &RayCast2d) { gizmos.line_2d( ray.ray.origin, ray.ray.origin + *ray.ray.direction * ray.max, - Color::WHITE, + LegacyColor::WHITE, ); for r in [1., 2., 3.] { - gizmos.circle_2d(ray.ray.origin, r, Color::FUCHSIA); + gizmos.circle_2d(ray.ray.origin, r, LegacyColor::FUCHSIA); } } @@ -331,7 +331,7 @@ fn ray_cast_system( gizmos.circle_2d( ray_cast.ray.origin + *ray_cast.ray.direction * toi, r, - Color::GREEN, + LegacyColor::GREEN, ); } } @@ -363,7 +363,7 @@ fn aabb_cast_system( + aabb_cast.aabb.center(), 0., aabb_cast.aabb.half_size() * 2., - Color::GREEN, + LegacyColor::GREEN, ); } } @@ -393,7 +393,7 @@ fn bounding_circle_cast_system( + *circle_cast.ray.ray.direction * toi + circle_cast.circle.center(), circle_cast.circle.radius(), - Color::GREEN, + LegacyColor::GREEN, ); } } @@ -412,7 +412,7 @@ fn aabb_intersection_system( ) { let center = get_intersection_position(&time); let aabb = Aabb2d::new(center, Vec2::splat(50.)); - gizmos.rect_2d(center, 0., aabb.half_size() * 2., Color::YELLOW); + gizmos.rect_2d(center, 0., aabb.half_size() * 2., LegacyColor::YELLOW); for (volume, mut intersects) in volumes.iter_mut() { let hit = match volume { @@ -431,7 +431,7 @@ fn circle_intersection_system( ) { let center = get_intersection_position(&time); let circle = BoundingCircle::new(center, 50.); - gizmos.circle_2d(center, circle.radius(), Color::YELLOW); + gizmos.circle_2d(center, circle.radius(), LegacyColor::YELLOW); for (volume, mut intersects) in volumes.iter_mut() { let hit = match volume { diff --git a/examples/2d/custom_gltf_vertex_attribute.rs b/examples/2d/custom_gltf_vertex_attribute.rs index 2f84665c31b6ef..1354838297f731 100644 --- a/examples/2d/custom_gltf_vertex_attribute.rs +++ b/examples/2d/custom_gltf_vertex_attribute.rs @@ -21,7 +21,7 @@ const ATTRIBUTE_BARYCENTRIC: MeshVertexAttribute = fn main() { App::new() .insert_resource(AmbientLight { - color: Color::WHITE, + color: LegacyColor::WHITE, brightness: 1.0 / 5.0f32, }) .add_plugins(( diff --git a/examples/2d/mesh2d.rs b/examples/2d/mesh2d.rs index 44fd13c9378e1f..c6a6ec9ef5f0a4 100644 --- a/examples/2d/mesh2d.rs +++ b/examples/2d/mesh2d.rs @@ -20,7 +20,7 @@ fn setup( commands.spawn(MaterialMesh2dBundle { mesh: meshes.add(Rectangle::default()).into(), transform: Transform::default().with_scale(Vec3::splat(128.)), - material: materials.add(Color::PURPLE), + material: materials.add(LegacyColor::PURPLE), ..default() }); } diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index 5e068fe2be02d4..1c892121136873 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -80,8 +80,8 @@ fn star( // Set the position attribute star.insert_attribute(Mesh::ATTRIBUTE_POSITION, v_pos); // And a RGB color attribute as well - let mut v_color: Vec = vec![Color::BLACK.as_linear_rgba_u32()]; - v_color.extend_from_slice(&[Color::YELLOW.as_linear_rgba_u32(); 10]); + let mut v_color: Vec = vec![LegacyColor::BLACK.as_linear_rgba_u32()]; + v_color.extend_from_slice(&[LegacyColor::YELLOW.as_linear_rgba_u32(); 10]); star.insert_attribute( MeshVertexAttribute::new("Vertex_Color", 1, VertexFormat::Uint32), v_color, diff --git a/examples/2d/mesh2d_vertex_color_texture.rs b/examples/2d/mesh2d_vertex_color_texture.rs index 351bcd0729fb6a..5e966044f45401 100644 --- a/examples/2d/mesh2d_vertex_color_texture.rs +++ b/examples/2d/mesh2d_vertex_color_texture.rs @@ -27,10 +27,10 @@ fn setup( let mut mesh = Mesh::from(Rectangle::default()); // Build vertex colors for the quad. One entry per vertex (the corners of the quad) let vertex_colors: Vec<[f32; 4]> = vec![ - Color::RED.as_rgba_f32(), - Color::GREEN.as_rgba_f32(), - Color::BLUE.as_rgba_f32(), - Color::WHITE.as_rgba_f32(), + LegacyColor::RED.as_rgba_f32(), + LegacyColor::GREEN.as_rgba_f32(), + LegacyColor::BLUE.as_rgba_f32(), + LegacyColor::WHITE.as_rgba_f32(), ]; // Insert the vertex colors as an attribute mesh.insert_attribute(Mesh::ATTRIBUTE_COLOR, vertex_colors); diff --git a/examples/2d/pixel_grid_snap.rs b/examples/2d/pixel_grid_snap.rs index 075dc06818f39f..ea76869e1215e9 100644 --- a/examples/2d/pixel_grid_snap.rs +++ b/examples/2d/pixel_grid_snap.rs @@ -85,7 +85,7 @@ fn setup_mesh( MaterialMesh2dBundle { mesh: meshes.add(Capsule2d::default()).into(), transform: Transform::from_xyz(40., 0., 2.).with_scale(Vec3::splat(32.)), - material: materials.add(Color::BLACK), + material: materials.add(LegacyColor::BLACK), ..default() }, Rotate, diff --git a/examples/2d/sprite_slice.rs b/examples/2d/sprite_slice.rs index c2cf40130b0914..3170b681192db8 100644 --- a/examples/2d/sprite_slice.rs +++ b/examples/2d/sprite_slice.rs @@ -114,7 +114,7 @@ fn setup(mut commands: Commands, asset_server: Res) { let style = TextStyle { font: font.clone(), font_size: 16.0, - color: Color::WHITE, + color: LegacyColor::WHITE, }; // Load textures diff --git a/examples/2d/text2d.rs b/examples/2d/text2d.rs index c48f2875a2a928..d384bcf0ecc211 100644 --- a/examples/2d/text2d.rs +++ b/examples/2d/text2d.rs @@ -36,7 +36,7 @@ fn setup(mut commands: Commands, asset_server: Res) { let text_style = TextStyle { font: font.clone(), font_size: 60.0, - color: Color::WHITE, + color: LegacyColor::WHITE, }; let text_justification = JustifyText::Center; // 2d camera @@ -72,14 +72,14 @@ fn setup(mut commands: Commands, asset_server: Res) { let slightly_smaller_text_style = TextStyle { font, font_size: 42.0, - color: Color::WHITE, + color: LegacyColor::WHITE, }; let box_size = Vec2::new(300.0, 200.0); let box_position = Vec2::new(0.0, -250.0); commands .spawn(SpriteBundle { sprite: Sprite { - color: Color::rgb(0.25, 0.25, 0.75), + color: LegacyColor::rgb(0.25, 0.25, 0.75), custom_size: Some(Vec2::new(box_size.x, box_size.y)), ..default() }, @@ -111,7 +111,7 @@ fn setup(mut commands: Commands, asset_server: Res) { commands .spawn(SpriteBundle { sprite: Sprite { - color: Color::rgb(0.20, 0.3, 0.70), + color: LegacyColor::rgb(0.20, 0.3, 0.70), custom_size: Some(Vec2::new(other_box_size.x, other_box_size.y)), ..default() }, @@ -139,10 +139,10 @@ fn setup(mut commands: Commands, asset_server: Res) { }); for (text_anchor, color) in [ - (Anchor::TopLeft, Color::RED), - (Anchor::TopRight, Color::GREEN), - (Anchor::BottomRight, Color::BLUE), - (Anchor::BottomLeft, Color::YELLOW), + (Anchor::TopLeft, LegacyColor::RED), + (Anchor::TopRight, LegacyColor::GREEN), + (Anchor::BottomRight, LegacyColor::BLUE), + (Anchor::BottomLeft, LegacyColor::YELLOW), ] { commands.spawn(Text2dBundle { text: Text { diff --git a/examples/2d/texture_atlas.rs b/examples/2d/texture_atlas.rs index 6b5e4eab575294..130494aa64c553 100644 --- a/examples/2d/texture_atlas.rs +++ b/examples/2d/texture_atlas.rs @@ -124,7 +124,7 @@ fn setup( let text_style: TextStyle = TextStyle { font: font.clone(), font_size: 50.0, - color: Color::WHITE, + color: LegacyColor::WHITE, }; // labels to indicate padding @@ -173,7 +173,7 @@ fn setup( let sampling_label_style = TextStyle { font, font_size: 30.0, - color: Color::WHITE, + color: LegacyColor::WHITE, }; let base_y = 170.0; // y position of the sprites diff --git a/examples/2d/transparency_2d.rs b/examples/2d/transparency_2d.rs index 8c4b2bd08589bf..4071a4fd08c1af 100644 --- a/examples/2d/transparency_2d.rs +++ b/examples/2d/transparency_2d.rs @@ -22,7 +22,7 @@ fn setup(mut commands: Commands, asset_server: Res) { commands.spawn(SpriteBundle { sprite: Sprite { // Alpha channel of the color controls transparency. - color: Color::rgba(0.0, 0.0, 1.0, 0.7), + color: LegacyColor::rgba(0.0, 0.0, 1.0, 0.7), ..default() }, texture: sprite_handle.clone(), @@ -31,7 +31,7 @@ fn setup(mut commands: Commands, asset_server: Res) { }); commands.spawn(SpriteBundle { sprite: Sprite { - color: Color::rgba(0.0, 1.0, 0.0, 0.3), + color: LegacyColor::rgba(0.0, 1.0, 0.0, 0.3), ..default() }, texture: sprite_handle, diff --git a/examples/3d/3d_scene.rs b/examples/3d/3d_scene.rs index 35ed4aa608373e..2737dd249b446a 100644 --- a/examples/3d/3d_scene.rs +++ b/examples/3d/3d_scene.rs @@ -18,14 +18,14 @@ fn setup( // circular base commands.spawn(PbrBundle { mesh: meshes.add(Circle::new(4.0)), - material: materials.add(Color::WHITE), + material: materials.add(LegacyColor::WHITE), transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)), ..default() }); // cube commands.spawn(PbrBundle { mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), - material: materials.add(Color::rgb_u8(124, 144, 255)), + material: materials.add(LegacyColor::rgb_u8(124, 144, 255)), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..default() }); diff --git a/examples/3d/3d_shapes.rs b/examples/3d/3d_shapes.rs index dc005f48e3f130..db9b3d5bcc632d 100644 --- a/examples/3d/3d_shapes.rs +++ b/examples/3d/3d_shapes.rs @@ -78,7 +78,7 @@ fn setup( // ground plane commands.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(50.0, 50.0)), - material: materials.add(Color::SILVER), + material: materials.add(LegacyColor::SILVER), ..default() }); diff --git a/examples/3d/3d_viewport_to_world.rs b/examples/3d/3d_viewport_to_world.rs index cb6bfe69d84829..ac13169de0179e 100644 --- a/examples/3d/3d_viewport_to_world.rs +++ b/examples/3d/3d_viewport_to_world.rs @@ -41,7 +41,7 @@ fn draw_cursor( point + ground.up() * 0.01, Direction3d::new_unchecked(ground.up()), // Up vector is already normalized. 0.2, - Color::WHITE, + LegacyColor::WHITE, ); } @@ -57,7 +57,7 @@ fn setup( commands.spawn(( PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(20., 20.)), - material: materials.add(Color::rgb(0.3, 0.5, 0.3)), + material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)), ..default() }, Ground, diff --git a/examples/3d/animated_material.rs b/examples/3d/animated_material.rs index 580a9d25ad43d2..0b6883be260aac 100644 --- a/examples/3d/animated_material.rs +++ b/examples/3d/animated_material.rs @@ -34,7 +34,7 @@ fn setup( for z in -1..2 { commands.spawn(PbrBundle { mesh: cube.clone(), - material: materials.add(Color::WHITE), + material: materials.add(LegacyColor::WHITE), transform: Transform::from_translation(Vec3::new(x as f32, 0.0, z as f32)), ..default() }); @@ -49,7 +49,7 @@ fn animate_materials( ) { for (i, material_handle) in material_handles.iter().enumerate() { if let Some(material) = materials.get_mut(material_handle) { - let color = Color::hsl( + let color = LegacyColor::hsl( ((i as f32 * 2.345 + time.elapsed_seconds_wrapped()) * 100.0) % 360.0, 1.0, 0.5, diff --git a/examples/3d/anti_aliasing.rs b/examples/3d/anti_aliasing.rs index 7428faa89cfa40..4ee365dce52d6d 100644 --- a/examples/3d/anti_aliasing.rs +++ b/examples/3d/anti_aliasing.rs @@ -261,7 +261,7 @@ fn setup( // Plane commands.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(50.0, 50.0)), - material: materials.add(Color::rgb(0.1, 0.2, 0.1)), + material: materials.add(LegacyColor::rgb(0.1, 0.2, 0.1)), ..default() }); @@ -329,7 +329,7 @@ fn setup( intensity: 150.0, }, FogSettings { - color: Color::rgba_u8(43, 44, 47, 255), + color: LegacyColor::rgba_u8(43, 44, 47, 255), falloff: FogFalloff::Linear { start: 1.0, end: 4.0, diff --git a/examples/3d/atmospheric_fog.rs b/examples/3d/atmospheric_fog.rs index e25e747729a2d5..dfba2b4f17230e 100644 --- a/examples/3d/atmospheric_fog.rs +++ b/examples/3d/atmospheric_fog.rs @@ -31,13 +31,13 @@ fn setup_camera_fog(mut commands: Commands) { ..default() }, FogSettings { - color: Color::rgba(0.35, 0.48, 0.66, 1.0), - directional_light_color: Color::rgba(1.0, 0.95, 0.85, 0.5), + color: LegacyColor::rgba(0.35, 0.48, 0.66, 1.0), + directional_light_color: LegacyColor::rgba(1.0, 0.95, 0.85, 0.5), directional_light_exponent: 30.0, falloff: FogFalloff::from_visibility_colors( 15.0, // distance in world units up to which objects retain visibility (>= 5% contrast) - Color::rgb(0.35, 0.5, 0.66), // atmospheric extinction color (after light is lost due to absorption by atmospheric particles) - Color::rgb(0.8, 0.844, 1.0), // atmospheric inscattering color (light gained due to scattering from the sun) + LegacyColor::rgb(0.35, 0.5, 0.66), // atmospheric extinction color (after light is lost due to absorption by atmospheric particles) + LegacyColor::rgb(0.8, 0.844, 1.0), // atmospheric inscattering color (light gained due to scattering from the sun) ), }, )); @@ -60,7 +60,7 @@ fn setup_terrain_scene( // Sun commands.spawn(DirectionalLightBundle { directional_light: DirectionalLight { - color: Color::rgb(0.98, 0.95, 0.82), + color: LegacyColor::rgb(0.98, 0.95, 0.82), shadows_enabled: true, ..default() }, @@ -81,7 +81,7 @@ fn setup_terrain_scene( PbrBundle { mesh: meshes.add(Cuboid::new(2.0, 1.0, 1.0)), material: materials.add(StandardMaterial { - base_color: Color::hex("888888").unwrap(), + base_color: LegacyColor::hex("888888").unwrap(), unlit: true, cull_mode: None, ..default() diff --git a/examples/3d/blend_modes.rs b/examples/3d/blend_modes.rs index 73918316ccd004..8cd05f17d820cd 100644 --- a/examples/3d/blend_modes.rs +++ b/examples/3d/blend_modes.rs @@ -36,7 +36,7 @@ fn setup( mut materials: ResMut>, asset_server: Res, ) { - let base_color = Color::rgba(0.9, 0.2, 0.3, 1.0); + let base_color = LegacyColor::rgba(0.9, 0.2, 0.3, 1.0); let icosphere_mesh = meshes.add(Sphere::new(0.9).mesh().ico(7).unwrap()); // Opaque @@ -140,8 +140,8 @@ fn setup( .id(); // Chessboard Plane - let black_material = materials.add(Color::BLACK); - let white_material = materials.add(Color::WHITE); + let black_material = materials.add(LegacyColor::BLACK); + let white_material = materials.add(LegacyColor::WHITE); let plane_mesh = meshes.add(Plane3d::default().mesh().size(2.0, 2.0)); @@ -188,7 +188,7 @@ fn setup( let label_text_style = TextStyle { font: asset_server.load("fonts/FiraMono-Medium.ttf"), font_size: 25.0, - color: Color::ORANGE, + color: LegacyColor::ORANGE, }; commands.spawn( diff --git a/examples/3d/bloom_3d.rs b/examples/3d/bloom_3d.rs index ada7f1d2adf508..dc7f3d187ec4d2 100644 --- a/examples/3d/bloom_3d.rs +++ b/examples/3d/bloom_3d.rs @@ -39,19 +39,19 @@ fn setup_scene( )); let material_emissive1 = materials.add(StandardMaterial { - emissive: Color::rgb_linear(2300.0, 900.0, 300.0), // 4. Put something bright in a dark environment to see the effect + emissive: LegacyColor::rgb_linear(2300.0, 900.0, 300.0), // 4. Put something bright in a dark environment to see the effect ..default() }); let material_emissive2 = materials.add(StandardMaterial { - emissive: Color::rgb_linear(300.0, 2300.0, 900.0), + emissive: LegacyColor::rgb_linear(300.0, 2300.0, 900.0), ..default() }); let material_emissive3 = materials.add(StandardMaterial { - emissive: Color::rgb_linear(900.0, 300.0, 2300.0), + emissive: LegacyColor::rgb_linear(900.0, 300.0, 2300.0), ..default() }); let material_non_emissive = materials.add(StandardMaterial { - base_color: Color::GRAY, + base_color: LegacyColor::GRAY, ..default() }); @@ -89,7 +89,7 @@ fn setup_scene( "", TextStyle { font_size: 20.0, - color: Color::BLACK, + color: LegacyColor::BLACK, ..default() }, ) diff --git a/examples/3d/deferred_rendering.rs b/examples/3d/deferred_rendering.rs index b10056ad055956..f6d9e1808231c5 100644 --- a/examples/3d/deferred_rendering.rs +++ b/examples/3d/deferred_rendering.rs @@ -48,7 +48,7 @@ fn setup( ..default() }, FogSettings { - color: Color::rgba_u8(43, 44, 47, 255), + color: LegacyColor::rgba_u8(43, 44, 47, 255), falloff: FogFalloff::Linear { start: 1.0, end: 8.0, @@ -95,7 +95,7 @@ fn setup( ..default() }); - let mut forward_mat: StandardMaterial = Color::rgb(0.1, 0.2, 0.1).into(); + let mut forward_mat: StandardMaterial = LegacyColor::rgb(0.1, 0.2, 0.1).into(); forward_mat.opaque_render_method = OpaqueRendererMethod::Forward; let forward_mat_h = materials.add(forward_mat); @@ -123,7 +123,7 @@ fn setup( ..default() }); - let sphere_color = Color::rgb(10.0, 4.0, 1.0); + let sphere_color = LegacyColor::rgb(10.0, 4.0, 1.0); let sphere_pos = Transform::from_xyz(0.4, 0.5, -0.8); // Emissive sphere let mut unlit_mat: StandardMaterial = sphere_color.into(); @@ -156,21 +156,21 @@ fn setup( let s_val = if i < 3 { 0.0 } else { 0.2 }; let material = if j == 0 { materials.add(StandardMaterial { - base_color: Color::rgb(s_val, s_val, 1.0), + base_color: LegacyColor::rgb(s_val, s_val, 1.0), perceptual_roughness: 0.089, metallic: 0.0, ..default() }) } else if j == 1 { materials.add(StandardMaterial { - base_color: Color::rgb(s_val, 1.0, s_val), + base_color: LegacyColor::rgb(s_val, 1.0, s_val), perceptual_roughness: 0.089, metallic: 0.0, ..default() }) } else { materials.add(StandardMaterial { - base_color: Color::rgb(1.0, s_val, s_val), + base_color: LegacyColor::rgb(1.0, s_val, s_val), perceptual_roughness: 0.089, metallic: 0.0, ..default() @@ -193,7 +193,7 @@ fn setup( PbrBundle { mesh: meshes.add(Cuboid::new(2.0, 1.0, 1.0)), material: materials.add(StandardMaterial { - base_color: Color::hex("888888").unwrap(), + base_color: LegacyColor::hex("888888").unwrap(), unlit: true, cull_mode: None, ..default() diff --git a/examples/3d/deterministic.rs b/examples/3d/deterministic.rs index 94149be6b738ad..fae88cbdaf2009 100644 --- a/examples/3d/deterministic.rs +++ b/examples/3d/deterministic.rs @@ -40,7 +40,7 @@ fn setup( let mesh = meshes.add(Plane3d::default().mesh().size(2.0, 2.0)); let nb_plane = 10; for i in 0..nb_plane { - let color = Color::hsl(i as f32 * 360.0 / nb_plane as f32, 1.0, 0.5); + let color = LegacyColor::hsl(i as f32 * 360.0 / nb_plane as f32, 1.0, 0.5); commands.spawn(PbrBundle { mesh: mesh.clone(), material: materials.add(StandardMaterial { diff --git a/examples/3d/fog.rs b/examples/3d/fog.rs index 50d95a3d518bd8..45705aa1bed987 100644 --- a/examples/3d/fog.rs +++ b/examples/3d/fog.rs @@ -35,7 +35,7 @@ fn setup_camera_fog(mut commands: Commands) { commands.spawn(( Camera3dBundle::default(), FogSettings { - color: Color::rgba(0.25, 0.25, 0.25, 1.0), + color: LegacyColor::rgba(0.25, 0.25, 0.25, 1.0), falloff: FogFalloff::Linear { start: 5.0, end: 20.0, @@ -51,7 +51,7 @@ fn setup_pyramid_scene( mut materials: ResMut>, ) { let stone = materials.add(StandardMaterial { - base_color: Color::hex("28221B").unwrap(), + base_color: LegacyColor::hex("28221B").unwrap(), perceptual_roughness: 1.0, ..default() }); @@ -71,7 +71,7 @@ fn setup_pyramid_scene( PbrBundle { mesh: meshes.add(Sphere::default()), material: materials.add(StandardMaterial { - base_color: Color::hex("126212CC").unwrap(), + base_color: LegacyColor::hex("126212CC").unwrap(), reflectance: 1.0, perceptual_roughness: 0.0, metallic: 0.5, @@ -102,7 +102,7 @@ fn setup_pyramid_scene( commands.spawn(PbrBundle { mesh: meshes.add(Cuboid::new(2.0, 1.0, 1.0)), material: materials.add(StandardMaterial { - base_color: Color::hex("888888").unwrap(), + base_color: LegacyColor::hex("888888").unwrap(), unlit: true, cull_mode: None, ..default() diff --git a/examples/3d/irradiance_volumes.rs b/examples/3d/irradiance_volumes.rs index 18ae956a09ab91..3d34dcecc67213 100644 --- a/examples/3d/irradiance_volumes.rs +++ b/examples/3d/irradiance_volumes.rs @@ -47,7 +47,7 @@ static SWITCH_TO_SPHERE_HELP_TEXT: &str = "Tab: Switch to a plain sphere mesh"; static CLICK_TO_MOVE_HELP_TEXT: &str = "Left click: Move the object"; -static GIZMO_COLOR: Color = Color::YELLOW; +static GIZMO_COLOR: LegacyColor = LegacyColor::YELLOW; static VOXEL_TRANSFORM: Mat4 = Mat4::from_cols_array_2d(&[ [-42.317566, 0.0, 0.0, 0.0], @@ -148,7 +148,7 @@ fn main() { .init_resource::() .init_resource::() .insert_resource(AmbientLight { - color: Color::WHITE, + color: LegacyColor::WHITE, brightness: 0.0, }) .add_systems(Startup, setup) @@ -362,7 +362,7 @@ impl AppStatus { TextStyle { font: asset_server.load("fonts/FiraMono-Medium.ttf"), font_size: 24.0, - color: Color::ANTIQUE_WHITE, + color: LegacyColor::ANTIQUE_WHITE, }, ) } @@ -531,7 +531,7 @@ impl FromWorld for ExampleAssets { let voxel_cube = mesh_assets.add(Cuboid::default()); let mut standard_material_assets = world.resource_mut::>(); - let main_material = standard_material_assets.add(Color::SILVER); + let main_material = standard_material_assets.add(LegacyColor::SILVER); ExampleAssets { main_sphere, @@ -580,7 +580,7 @@ fn create_cubes( let resolution = image.texture_descriptor.size; let voxel_cube_material = voxel_visualization_material_assets.add(ExtendedMaterial { - base: StandardMaterial::from(Color::RED), + base: StandardMaterial::from(LegacyColor::RED), extension: VoxelVisualizationExtension { irradiance_volume_info: VoxelVisualizationIrradianceVolumeInfo { transform: VOXEL_TRANSFORM.inverse(), diff --git a/examples/3d/lighting.rs b/examples/3d/lighting.rs index e73c9bb7289358..5582cf669d41c0 100644 --- a/examples/3d/lighting.rs +++ b/examples/3d/lighting.rs @@ -40,7 +40,7 @@ fn setup( commands.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(10.0, 10.0)), material: materials.add(StandardMaterial { - base_color: Color::WHITE, + base_color: LegacyColor::WHITE, perceptual_roughness: 1.0, ..default() }), @@ -54,7 +54,7 @@ fn setup( mesh: meshes.add(Cuboid::new(5.0, 0.15, 5.0)), transform, material: materials.add(StandardMaterial { - base_color: Color::INDIGO, + base_color: LegacyColor::INDIGO, perceptual_roughness: 1.0, ..default() }), @@ -67,7 +67,7 @@ fn setup( mesh: meshes.add(Cuboid::new(5.0, 0.15, 5.0)), transform, material: materials.add(StandardMaterial { - base_color: Color::INDIGO, + base_color: LegacyColor::INDIGO, perceptual_roughness: 1.0, ..default() }), @@ -98,7 +98,7 @@ fn setup( PbrBundle { mesh: meshes.add(Cuboid::default()), material: materials.add(StandardMaterial { - base_color: Color::PINK, + base_color: LegacyColor::PINK, ..default() }), transform: Transform::from_xyz(0.0, 0.5, 0.0), @@ -111,7 +111,7 @@ fn setup( PbrBundle { mesh: meshes.add(Sphere::new(0.5).mesh().uv(32, 18)), material: materials.add(StandardMaterial { - base_color: Color::LIME_GREEN, + base_color: LegacyColor::LIME_GREEN, ..default() }), transform: Transform::from_xyz(1.5, 1.0, 1.5), @@ -122,7 +122,7 @@ fn setup( // ambient light commands.insert_resource(AmbientLight { - color: Color::ORANGE_RED, + color: LegacyColor::ORANGE_RED, brightness: 0.02, }); @@ -133,7 +133,7 @@ fn setup( transform: Transform::from_xyz(1.0, 2.0, 0.0), point_light: PointLight { intensity: 4000.0, // lumens - roughly a 300W non-halogen incandescent bulb - color: Color::RED, + color: LegacyColor::RED, shadows_enabled: true, ..default() }, @@ -143,8 +143,8 @@ fn setup( builder.spawn(PbrBundle { mesh: meshes.add(Sphere::new(0.1).mesh().uv(32, 18)), material: materials.add(StandardMaterial { - base_color: Color::RED, - emissive: Color::rgba_linear(7.13, 0.0, 0.0, 0.0), + base_color: LegacyColor::RED, + emissive: LegacyColor::rgba_linear(7.13, 0.0, 0.0, 0.0), ..default() }), ..default() @@ -158,7 +158,7 @@ fn setup( .looking_at(Vec3::new(-1.0, 0.0, 0.0), Vec3::Z), spot_light: SpotLight { intensity: 4000.0, // lumens - roughly a 300W non-halogen incandescent bulb - color: Color::GREEN, + color: LegacyColor::GREEN, shadows_enabled: true, inner_angle: 0.6, outer_angle: 0.8, @@ -171,8 +171,8 @@ 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: Color::GREEN, - emissive: Color::rgba_linear(0.0, 7.13, 0.0, 0.0), + base_color: LegacyColor::GREEN, + emissive: LegacyColor::rgba_linear(0.0, 7.13, 0.0, 0.0), ..default() }), ..default() @@ -186,7 +186,7 @@ fn setup( transform: Transform::from_xyz(0.0, 4.0, 0.0), point_light: PointLight { intensity: 4000.0, // lumens - roughly a 300W non-halogen incandescent bulb - color: Color::BLUE, + color: LegacyColor::BLUE, shadows_enabled: true, ..default() }, @@ -196,8 +196,8 @@ fn setup( builder.spawn(PbrBundle { mesh: meshes.add(Sphere::new(0.1).mesh().uv(32, 18)), material: materials.add(StandardMaterial { - base_color: Color::BLUE, - emissive: Color::rgba_linear(0.0, 0.0, 7.13, 0.0), + base_color: LegacyColor::BLUE, + emissive: LegacyColor::rgba_linear(0.0, 0.0, 7.13, 0.0), ..default() }), ..default() diff --git a/examples/3d/lightmaps.rs b/examples/3d/lightmaps.rs index 632d361ca4964b..2e8f9cdef46b5b 100644 --- a/examples/3d/lightmaps.rs +++ b/examples/3d/lightmaps.rs @@ -36,7 +36,7 @@ fn add_lightmaps_to_meshes( let exposure = 250.0; for (entity, name, material) in meshes.iter() { if &**name == "Light" { - materials.get_mut(material).unwrap().emissive = Color::WHITE * exposure; + materials.get_mut(material).unwrap().emissive = LegacyColor::WHITE * exposure; continue; } diff --git a/examples/3d/lines.rs b/examples/3d/lines.rs index fa6158aa702599..424117e76ecfe7 100644 --- a/examples/3d/lines.rs +++ b/examples/3d/lines.rs @@ -36,7 +36,7 @@ fn setup( }), transform: Transform::from_xyz(-1.5, 0.0, 0.0), material: materials.add(LineMaterial { - color: Color::GREEN, + color: LegacyColor::GREEN, }), ..default() }); @@ -51,7 +51,9 @@ fn setup( ], }), transform: Transform::from_xyz(0.5, 0.0, 0.0), - material: materials.add(LineMaterial { color: Color::BLUE }), + material: materials.add(LineMaterial { + color: LegacyColor::BLUE, + }), ..default() }); @@ -65,7 +67,7 @@ fn setup( #[derive(Asset, TypePath, Default, AsBindGroup, Debug, Clone)] struct LineMaterial { #[uniform(0)] - color: Color, + color: LegacyColor, } impl Material for LineMaterial { diff --git a/examples/3d/orthographic.rs b/examples/3d/orthographic.rs index 489f93a2c28148..20ee4cd2601dcc 100644 --- a/examples/3d/orthographic.rs +++ b/examples/3d/orthographic.rs @@ -30,31 +30,31 @@ fn setup( // plane commands.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)), - material: materials.add(Color::rgb(0.3, 0.5, 0.3)), + material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)), ..default() }); // cubes commands.spawn(PbrBundle { mesh: meshes.add(Cuboid::default()), - material: materials.add(Color::rgb(0.8, 0.7, 0.6)), + material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)), transform: Transform::from_xyz(1.5, 0.5, 1.5), ..default() }); commands.spawn(PbrBundle { mesh: meshes.add(Cuboid::default()), - material: materials.add(Color::rgb(0.8, 0.7, 0.6)), + material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)), transform: Transform::from_xyz(1.5, 0.5, -1.5), ..default() }); commands.spawn(PbrBundle { mesh: meshes.add(Cuboid::default()), - material: materials.add(Color::rgb(0.8, 0.7, 0.6)), + material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)), transform: Transform::from_xyz(-1.5, 0.5, 1.5), ..default() }); commands.spawn(PbrBundle { mesh: meshes.add(Cuboid::default()), - material: materials.add(Color::rgb(0.8, 0.7, 0.6)), + material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)), transform: Transform::from_xyz(-1.5, 0.5, -1.5), ..default() }); diff --git a/examples/3d/parallax_mapping.rs b/examples/3d/parallax_mapping.rs index 46f525fc3b16f0..32fc04226c32fd 100644 --- a/examples/3d/parallax_mapping.rs +++ b/examples/3d/parallax_mapping.rs @@ -243,7 +243,7 @@ fn setup( // with roughness and reflectance set. perceptual_roughness: 0.45, reflectance: 0.18, - ..Color::rgb_u8(0, 80, 0).into() + ..LegacyColor::rgb_u8(0, 80, 0).into() }), transform: Transform::from_xyz(0.0, -1.0, 0.0), ..default() diff --git a/examples/3d/parenting.rs b/examples/3d/parenting.rs index e6c8ebcfc614a3..c59b3009f5a509 100644 --- a/examples/3d/parenting.rs +++ b/examples/3d/parenting.rs @@ -30,7 +30,7 @@ fn setup( ) { let cube_handle = meshes.add(Cuboid::new(2.0, 2.0, 2.0)); let cube_material_handle = materials.add(StandardMaterial { - base_color: Color::rgb(0.8, 0.7, 0.6), + base_color: LegacyColor::rgb(0.8, 0.7, 0.6), ..default() }); diff --git a/examples/3d/pbr.rs b/examples/3d/pbr.rs index 159d63f2bcc553..19a72e32bc75b3 100644 --- a/examples/3d/pbr.rs +++ b/examples/3d/pbr.rs @@ -27,7 +27,7 @@ fn setup( commands.spawn(PbrBundle { mesh: sphere_mesh.clone(), material: materials.add(StandardMaterial { - base_color: Color::hex("#ffd891").unwrap(), + base_color: LegacyColor::hex("#ffd891").unwrap(), // vary key PBR parameters on a grid of spheres to show the effect metallic: y01, perceptual_roughness: x01, @@ -42,7 +42,7 @@ fn setup( commands.spawn(PbrBundle { mesh: sphere_mesh, material: materials.add(StandardMaterial { - base_color: Color::hex("#ffd891").unwrap(), + base_color: LegacyColor::hex("#ffd891").unwrap(), // vary key PBR parameters on a grid of spheres to show the effect unlit: true, ..default() @@ -103,7 +103,7 @@ fn setup( "Loading Environment Map...", TextStyle { font_size: 36.0, - color: Color::RED, + color: LegacyColor::RED, ..default() }, ) diff --git a/examples/3d/reflection_probes.rs b/examples/3d/reflection_probes.rs index aea1c1abf54ecd..aa0bd348d58ad5 100644 --- a/examples/3d/reflection_probes.rs +++ b/examples/3d/reflection_probes.rs @@ -128,7 +128,7 @@ fn spawn_sphere( commands.spawn(PbrBundle { mesh: sphere_mesh.clone(), material: materials.add(StandardMaterial { - base_color: Color::hex("#ffd891").unwrap(), + base_color: LegacyColor::hex("#ffd891").unwrap(), metallic: 1.0, perceptual_roughness: 0.0, ..StandardMaterial::default() @@ -293,7 +293,7 @@ impl AppStatus { TextStyle { font: asset_server.load("fonts/FiraMono-Medium.ttf"), font_size: 24.0, - color: Color::ANTIQUE_WHITE, + color: LegacyColor::ANTIQUE_WHITE, }, ) } diff --git a/examples/3d/render_to_texture.rs b/examples/3d/render_to_texture.rs index 588dcbd6b51c94..1e71871d3b34a5 100644 --- a/examples/3d/render_to_texture.rs +++ b/examples/3d/render_to_texture.rs @@ -64,7 +64,7 @@ fn setup( let cube_handle = meshes.add(Cuboid::new(4.0, 4.0, 4.0)); let cube_material_handle = materials.add(StandardMaterial { - base_color: Color::rgb(0.8, 0.7, 0.6), + base_color: LegacyColor::rgb(0.8, 0.7, 0.6), reflectance: 0.02, unlit: false, ..default() @@ -103,7 +103,7 @@ fn setup( // render before the "main pass" camera order: -1, target: image_handle.clone().into(), - clear_color: Color::WHITE.into(), + clear_color: LegacyColor::WHITE.into(), ..default() }, transform: Transform::from_translation(Vec3::new(0.0, 0.0, 15.0)) diff --git a/examples/3d/shadow_biases.rs b/examples/3d/shadow_biases.rs index 3d5150f3f62864..7079f1717d7ae6 100644 --- a/examples/3d/shadow_biases.rs +++ b/examples/3d/shadow_biases.rs @@ -38,7 +38,7 @@ fn setup( let sphere_radius = 0.25; let white_handle = materials.add(StandardMaterial { - base_color: Color::WHITE, + base_color: LegacyColor::WHITE, perceptual_roughness: 1.0, ..default() }); @@ -58,7 +58,7 @@ fn setup( point_light: PointLight { intensity: 0.0, range: spawn_plane_depth, - color: Color::WHITE, + color: LegacyColor::WHITE, shadow_depth_bias: 0.0, shadow_normal_bias: 0.0, shadows_enabled: true, @@ -125,7 +125,7 @@ fn setup( ..default() }, z_index: ZIndex::Global(i32::MAX), - background_color: Color::BLACK.with_a(0.75).into(), + background_color: LegacyColor::BLACK.with_a(0.75).into(), ..default() }) .with_children(|c| { diff --git a/examples/3d/shadow_caster_receiver.rs b/examples/3d/shadow_caster_receiver.rs index d0d04cfe2eea1d..95ae0c549d1fe3 100644 --- a/examples/3d/shadow_caster_receiver.rs +++ b/examples/3d/shadow_caster_receiver.rs @@ -32,7 +32,7 @@ fn setup( let sphere_radius = 0.25; let white_handle = materials.add(StandardMaterial { - base_color: Color::WHITE, + base_color: LegacyColor::WHITE, perceptual_roughness: 1.0, ..default() }); @@ -41,7 +41,7 @@ fn setup( // sphere - initially a caster commands.spawn(PbrBundle { mesh: sphere_handle.clone(), - material: materials.add(Color::RED), + material: materials.add(LegacyColor::RED), transform: Transform::from_xyz(-1.0, spawn_height, 0.0), ..default() }); @@ -50,7 +50,7 @@ fn setup( commands.spawn(( PbrBundle { mesh: sphere_handle, - material: materials.add(Color::BLUE), + material: materials.add(LegacyColor::BLUE), transform: Transform::from_xyz(1.0, spawn_height, 0.0), ..default() }, @@ -61,7 +61,7 @@ fn setup( commands.spawn(( PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(20.0, 20.0)), - material: materials.add(Color::GREEN), + material: materials.add(LegacyColor::GREEN), transform: Transform::from_xyz(0.0, 1.0, -10.0), ..default() }, @@ -83,7 +83,7 @@ fn setup( point_light: PointLight { intensity: 0.0, range: spawn_plane_depth, - color: Color::WHITE, + color: LegacyColor::WHITE, shadows_enabled: true, ..default() }, diff --git a/examples/3d/skybox.rs b/examples/3d/skybox.rs index 518a06cf3c71fb..6a7efad5420d70 100644 --- a/examples/3d/skybox.rs +++ b/examples/3d/skybox.rs @@ -88,7 +88,7 @@ fn setup(mut commands: Commands, asset_server: Res) { // NOTE: The ambient light is used to scale how bright the environment map is so with a bright // environment map, use an appropriate color and brightness to match commands.insert_resource(AmbientLight { - color: Color::rgb_u8(210, 220, 240), + color: LegacyColor::rgb_u8(210, 220, 240), brightness: 1.0, }); diff --git a/examples/3d/spherical_area_lights.rs b/examples/3d/spherical_area_lights.rs index 494c6e58a7b318..aa9b8ae4066ff5 100644 --- a/examples/3d/spherical_area_lights.rs +++ b/examples/3d/spherical_area_lights.rs @@ -28,7 +28,7 @@ fn setup( commands.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(100.0, 100.0)), material: materials.add(StandardMaterial { - base_color: Color::rgb(0.2, 0.2, 0.2), + base_color: LegacyColor::rgb(0.2, 0.2, 0.2), perceptual_roughness: 0.08, ..default() }), @@ -51,7 +51,7 @@ fn setup( .spawn(PbrBundle { mesh: mesh.clone(), material: materials.add(StandardMaterial { - base_color: Color::rgb(0.5, 0.5, 1.0), + base_color: LegacyColor::rgb(0.5, 0.5, 1.0), unlit: true, ..default() }), @@ -63,7 +63,7 @@ fn setup( children.spawn(PointLightBundle { point_light: PointLight { radius, - color: Color::rgb(0.2, 0.2, 1.0), + color: LegacyColor::rgb(0.2, 0.2, 1.0), ..default() }, ..default() diff --git a/examples/3d/split_screen.rs b/examples/3d/split_screen.rs index 5fe2900e206a1e..290ae66a3ee170 100644 --- a/examples/3d/split_screen.rs +++ b/examples/3d/split_screen.rs @@ -24,7 +24,7 @@ fn setup( // plane commands.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(100.0, 100.0)), - material: materials.add(Color::rgb(0.3, 0.5, 0.3)), + material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)), ..default() }); @@ -145,8 +145,8 @@ fn setup( align_items: AlignItems::Center, ..default() }, - border_color: Color::WHITE.into(), - background_color: Color::DARK_GRAY.into(), + border_color: LegacyColor::WHITE.into(), + background_color: LegacyColor::DARK_GRAY.into(), ..default() }, )) diff --git a/examples/3d/spotlight.rs b/examples/3d/spotlight.rs index 343fad122e6870..81c3472af3bb37 100644 --- a/examples/3d/spotlight.rs +++ b/examples/3d/spotlight.rs @@ -29,14 +29,14 @@ fn setup( // ground plane commands.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(100.0, 100.0)), - material: materials.add(Color::WHITE), + material: materials.add(LegacyColor::WHITE), ..default() }); // cubes let mut rng = StdRng::seed_from_u64(19878367467713); let cube_mesh = meshes.add(Cuboid::new(0.5, 0.5, 0.5)); - let blue = materials.add(Color::rgb_u8(124, 144, 255)); + let blue = materials.add(LegacyColor::rgb_u8(124, 144, 255)); for _ in 0..40 { let x = rng.gen_range(-5.0..5.0); let y = rng.gen_range(0.0..3.0); @@ -55,13 +55,13 @@ fn setup( let sphere_mesh = meshes.add(Sphere::new(0.05).mesh().uv(32, 18)); let sphere_mesh_direction = meshes.add(Sphere::new(0.1).mesh().uv(32, 18)); let red_emissive = materials.add(StandardMaterial { - base_color: Color::RED, - emissive: Color::rgba_linear(100.0, 0.0, 0.0, 0.0), + base_color: LegacyColor::RED, + emissive: LegacyColor::rgba_linear(100.0, 0.0, 0.0, 0.0), ..default() }); let maroon_emissive = materials.add(StandardMaterial { - base_color: Color::MAROON, - emissive: Color::rgba_linear(50.0, 0.0, 0.0, 0.0), + base_color: LegacyColor::MAROON, + emissive: LegacyColor::rgba_linear(50.0, 0.0, 0.0, 0.0), ..default() }); for x in 0..4 { @@ -75,7 +75,7 @@ fn setup( .looking_at(Vec3::new(1.0 + x, 0.0, z), Vec3::X), spot_light: SpotLight { intensity: 4000.0, // lumens - color: Color::WHITE, + color: LegacyColor::WHITE, shadows_enabled: true, inner_angle: PI / 4.0 * 0.85, outer_angle: PI / 4.0, diff --git a/examples/3d/ssao.rs b/examples/3d/ssao.rs index 3c98a587967c5b..a7399245e6c219 100644 --- a/examples/3d/ssao.rs +++ b/examples/3d/ssao.rs @@ -42,7 +42,7 @@ fn setup( .insert(TemporalAntiAliasBundle::default()); let material = materials.add(StandardMaterial { - base_color: Color::rgb(0.5, 0.5, 0.5), + base_color: LegacyColor::rgb(0.5, 0.5, 0.5), perceptual_roughness: 1.0, reflectance: 0.0, ..default() @@ -69,7 +69,7 @@ fn setup( PbrBundle { mesh: meshes.add(Sphere::new(0.4).mesh().uv(72, 36)), material: materials.add(StandardMaterial { - base_color: Color::rgb(0.4, 0.4, 0.4), + base_color: LegacyColor::rgb(0.4, 0.4, 0.4), perceptual_roughness: 1.0, reflectance: 0.0, ..default() diff --git a/examples/3d/texture.rs b/examples/3d/texture.rs index 9dc7aac7e77470..8d3898bce11929 100644 --- a/examples/3d/texture.rs +++ b/examples/3d/texture.rs @@ -36,7 +36,7 @@ fn setup( // this material modulates the texture to make it red (and slightly transparent) let red_material_handle = materials.add(StandardMaterial { - base_color: Color::rgba(1.0, 0.0, 0.0, 0.5), + base_color: LegacyColor::rgba(1.0, 0.0, 0.0, 0.5), base_color_texture: Some(texture_handle.clone()), alpha_mode: AlphaMode::Blend, unlit: true, @@ -45,7 +45,7 @@ fn setup( // and lets make this one blue! (and also slightly transparent) let blue_material_handle = materials.add(StandardMaterial { - base_color: Color::rgba(0.0, 0.0, 1.0, 0.5), + base_color: LegacyColor::rgba(0.0, 0.0, 1.0, 0.5), base_color_texture: Some(texture_handle), alpha_mode: AlphaMode::Blend, unlit: true, diff --git a/examples/3d/tonemapping.rs b/examples/3d/tonemapping.rs index 04070b19842e08..6bfec01dc3dedf 100644 --- a/examples/3d/tonemapping.rs +++ b/examples/3d/tonemapping.rs @@ -66,7 +66,7 @@ fn setup( ..default() }, FogSettings { - color: Color::rgba_u8(43, 44, 47, 255), + color: LegacyColor::rgba_u8(43, 44, 47, 255), falloff: FogFalloff::Linear { start: 1.0, end: 8.0, @@ -109,7 +109,7 @@ fn setup_basic_scene( commands.spawn(( PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(50.0, 50.0)), - material: materials.add(Color::rgb(0.1, 0.2, 0.1)), + material: materials.add(LegacyColor::rgb(0.1, 0.2, 0.1)), ..default() }, SceneNumber(1), @@ -141,21 +141,21 @@ fn setup_basic_scene( let s_val = if i < 3 { 0.0 } else { 0.2 }; let material = if j == 0 { materials.add(StandardMaterial { - base_color: Color::rgb(s_val, s_val, 1.0), + base_color: LegacyColor::rgb(s_val, s_val, 1.0), perceptual_roughness: 0.089, metallic: 0.0, ..default() }) } else if j == 1 { materials.add(StandardMaterial { - base_color: Color::rgb(s_val, 1.0, s_val), + base_color: LegacyColor::rgb(s_val, 1.0, s_val), perceptual_roughness: 0.089, metallic: 0.0, ..default() }) } else { materials.add(StandardMaterial { - base_color: Color::rgb(1.0, s_val, s_val), + base_color: LegacyColor::rgb(1.0, s_val, s_val), perceptual_roughness: 0.089, metallic: 0.0, ..default() @@ -266,7 +266,7 @@ fn setup_image_viewer_scene( "Drag and drop an HDR or EXR file", TextStyle { font_size: 36.0, - color: Color::BLACK, + color: LegacyColor::BLACK, ..default() }, ) diff --git a/examples/3d/transmission.rs b/examples/3d/transmission.rs index d73b7a1f535f94..cc423c6961fbdd 100644 --- a/examples/3d/transmission.rs +++ b/examples/3d/transmission.rs @@ -41,7 +41,7 @@ fn main() { let mut app = App::new(); app.add_plugins(DefaultPlugins) - .insert_resource(ClearColor(Color::BLACK)) + .insert_resource(ClearColor(LegacyColor::BLACK)) .insert_resource(PointLightShadowMap { size: 2048 }) .insert_resource(AmbientLight { brightness: 0.0, @@ -117,7 +117,7 @@ fn setup( PbrBundle { mesh: cylinder_mesh, material: materials.add(StandardMaterial { - base_color: Color::rgba(0.9, 0.2, 0.3, 1.0), + base_color: LegacyColor::rgba(0.9, 0.2, 0.3, 1.0), diffuse_transmission: 0.7, perceptual_roughness: 0.32, thickness: 0.2, @@ -138,7 +138,7 @@ fn setup( PbrBundle { mesh: icosphere_mesh.clone(), material: materials.add(StandardMaterial { - emissive: Color::ANTIQUE_WHITE * 80.0 + Color::ORANGE_RED * 16.0, + emissive: LegacyColor::ANTIQUE_WHITE * 80.0 + LegacyColor::ORANGE_RED * 16.0, diffuse_transmission: 1.0, ..default() }), @@ -154,7 +154,7 @@ fn setup( PbrBundle { mesh: icosphere_mesh.clone(), material: materials.add(StandardMaterial { - base_color: Color::WHITE, + base_color: LegacyColor::WHITE, specular_transmission: 0.9, diffuse_transmission: 1.0, thickness: 1.8, @@ -177,7 +177,7 @@ fn setup( PbrBundle { mesh: icosphere_mesh.clone(), material: materials.add(StandardMaterial { - base_color: Color::RED, + base_color: LegacyColor::RED, specular_transmission: 0.9, diffuse_transmission: 1.0, thickness: 1.8, @@ -200,7 +200,7 @@ fn setup( PbrBundle { mesh: icosphere_mesh.clone(), material: materials.add(StandardMaterial { - base_color: Color::GREEN, + base_color: LegacyColor::GREEN, specular_transmission: 0.9, diffuse_transmission: 1.0, thickness: 1.8, @@ -223,7 +223,7 @@ fn setup( PbrBundle { mesh: icosphere_mesh, material: materials.add(StandardMaterial { - base_color: Color::BLUE, + base_color: LegacyColor::BLUE, specular_transmission: 0.9, diffuse_transmission: 1.0, thickness: 1.8, @@ -243,14 +243,14 @@ fn setup( // Chessboard Plane let black_material = materials.add(StandardMaterial { - base_color: Color::BLACK, + base_color: LegacyColor::BLACK, reflectance: 0.3, perceptual_roughness: 0.8, ..default() }); let white_material = materials.add(StandardMaterial { - base_color: Color::WHITE, + base_color: LegacyColor::WHITE, reflectance: 0.3, perceptual_roughness: 0.8, ..default() @@ -283,7 +283,7 @@ fn setup( PbrBundle { mesh: plane_mesh, material: materials.add(StandardMaterial { - base_color: Color::WHITE, + base_color: LegacyColor::WHITE, diffuse_transmission: 0.6, perceptual_roughness: 0.8, reflectance: 1.0, @@ -309,7 +309,7 @@ fn setup( PointLightBundle { transform: Transform::from_xyz(-1.0, 1.7, 0.0), point_light: PointLight { - color: Color::ANTIQUE_WHITE * 0.8 + Color::ORANGE_RED * 0.2, + color: LegacyColor::ANTIQUE_WHITE * 0.8 + LegacyColor::ORANGE_RED * 0.2, intensity: 4_000.0, radius: 0.2, range: 5.0, @@ -350,7 +350,7 @@ fn setup( // Controls Text let text_style = TextStyle { font_size: 18.0, - color: Color::WHITE, + color: LegacyColor::WHITE, ..Default::default() }; diff --git a/examples/3d/transparency_3d.rs b/examples/3d/transparency_3d.rs index a6e6b9479e37d0..8395db0854bc14 100644 --- a/examples/3d/transparency_3d.rs +++ b/examples/3d/transparency_3d.rs @@ -21,7 +21,7 @@ fn setup( // Opaque plane, uses `alpha_mode: Opaque` by default commands.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(6.0, 6.0)), - material: materials.add(Color::rgb(0.3, 0.5, 0.3)), + material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)), ..default() }); @@ -33,7 +33,7 @@ fn setup( // We set it to 0.0 here, because it will be changed over time in the // `fade_transparency` function. // Note that the transparency has no effect on the objects shadow. - base_color: Color::rgba(0.2, 0.7, 0.1, 0.0), + base_color: LegacyColor::rgba(0.2, 0.7, 0.1, 0.0), // Mask sets a cutoff for transparency. Alpha values below are fully transparent, // alpha values above are fully opaque. alpha_mode: AlphaMode::Mask(0.5), @@ -47,7 +47,7 @@ fn setup( commands.spawn(PbrBundle { mesh: meshes.add(Sphere::new(0.5).mesh().ico(3).unwrap()), material: materials.add(StandardMaterial { - base_color: Color::rgba(0.2, 0.7, 0.1, 0.0), + base_color: LegacyColor::rgba(0.2, 0.7, 0.1, 0.0), alpha_mode: AlphaMode::Mask(0.5), unlit: true, ..default() @@ -62,7 +62,7 @@ fn setup( // Notice how there is no need to set the `alpha_mode` explicitly here. // When converting a color to a material using `into()`, the alpha mode is // automatically set to `Blend` if the alpha channel is anything lower than 1.0. - material: materials.add(Color::rgba(0.5, 0.5, 1.0, 0.0)), + material: materials.add(LegacyColor::rgba(0.5, 0.5, 1.0, 0.0)), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..default() }); @@ -70,7 +70,7 @@ fn setup( // Opaque sphere commands.spawn(PbrBundle { mesh: meshes.add(Sphere::new(0.5).mesh().ico(3).unwrap()), - material: materials.add(Color::rgb(0.7, 0.2, 0.1)), + material: materials.add(LegacyColor::rgb(0.7, 0.2, 0.1)), transform: Transform::from_xyz(0.0, 0.5, -1.5), ..default() }); diff --git a/examples/3d/two_passes.rs b/examples/3d/two_passes.rs index 14019f95fae7e8..4bd625d194f377 100644 --- a/examples/3d/two_passes.rs +++ b/examples/3d/two_passes.rs @@ -18,14 +18,14 @@ fn setup( // Plane commands.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)), - material: materials.add(Color::rgb(0.3, 0.5, 0.3)), + material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)), ..default() }); // Cube commands.spawn(PbrBundle { mesh: meshes.add(Cuboid::default()), - material: materials.add(Color::rgb(0.8, 0.7, 0.6)), + material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..default() }); diff --git a/examples/3d/vertex_colors.rs b/examples/3d/vertex_colors.rs index 3fd417c24e7578..022bbea6abf646 100644 --- a/examples/3d/vertex_colors.rs +++ b/examples/3d/vertex_colors.rs @@ -18,7 +18,7 @@ fn setup( // plane commands.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)), - material: materials.add(Color::rgb(0.3, 0.5, 0.3)), + material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)), ..default() }); // cube @@ -38,7 +38,7 @@ fn setup( // This is the default color, but note that vertex colors are // multiplied by the base color, so you'll likely want this to be // white if using vertex colors. - material: materials.add(Color::rgb(1., 1., 1.)), + material: materials.add(LegacyColor::rgb(1., 1., 1.)), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..default() }); diff --git a/examples/3d/wireframe.rs b/examples/3d/wireframe.rs index 36d6195accf2d7..4fe8c841768a1d 100644 --- a/examples/3d/wireframe.rs +++ b/examples/3d/wireframe.rs @@ -40,7 +40,7 @@ fn main() { global: true, // Controls the default color of all wireframes. Used as the default color for global wireframes. // Can be changed per mesh using the `WireframeColor` component. - default_color: Color::WHITE, + default_color: LegacyColor::WHITE, }) .add_systems(Startup, setup) .add_systems(Update, update_colors) @@ -56,7 +56,7 @@ fn setup( // plane commands.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)), - material: materials.add(Color::BLUE), + material: materials.add(LegacyColor::BLUE), ..default() }); @@ -64,7 +64,7 @@ fn setup( commands.spawn(( PbrBundle { mesh: meshes.add(Cuboid::default()), - material: materials.add(Color::RED), + material: materials.add(LegacyColor::RED), transform: Transform::from_xyz(-1.0, 0.5, -1.0), ..default() }, @@ -73,7 +73,7 @@ fn setup( // Orange cube: Follows global wireframe setting commands.spawn(PbrBundle { mesh: meshes.add(Cuboid::default()), - material: materials.add(Color::ORANGE), + material: materials.add(LegacyColor::ORANGE), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..default() }); @@ -81,7 +81,7 @@ fn setup( commands.spawn(( PbrBundle { mesh: meshes.add(Cuboid::default()), - material: materials.add(Color::GREEN), + material: materials.add(LegacyColor::GREEN), transform: Transform::from_xyz(1.0, 0.5, 1.0), ..default() }, @@ -89,7 +89,7 @@ fn setup( // This lets you configure the wireframe color of this entity. // If not set, this will use the color in `WireframeConfig` WireframeColor { - color: Color::GREEN, + color: LegacyColor::GREEN, }, )); @@ -146,20 +146,20 @@ Color: {:?} // Toggle the global wireframe color if keyboard_input.just_pressed(KeyCode::KeyX) { - config.default_color = if config.default_color == Color::WHITE { - Color::PINK + config.default_color = if config.default_color == LegacyColor::WHITE { + LegacyColor::PINK } else { - Color::WHITE + LegacyColor::WHITE }; } // 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 == Color::GREEN { - Color::RED + color.color = if color.color == LegacyColor::GREEN { + LegacyColor::RED } else { - Color::GREEN + LegacyColor::GREEN }; } } diff --git a/examples/animation/animated_fox.rs b/examples/animation/animated_fox.rs index fc3b5b4b7e8c22..d929c54cab57f1 100644 --- a/examples/animation/animated_fox.rs +++ b/examples/animation/animated_fox.rs @@ -8,7 +8,7 @@ use bevy::{animation::RepeatAnimation, pbr::CascadeShadowConfigBuilder, prelude: fn main() { App::new() .insert_resource(AmbientLight { - color: Color::WHITE, + color: LegacyColor::WHITE, brightness: 2000., }) .add_plugins(DefaultPlugins) @@ -46,7 +46,7 @@ fn setup( // Plane commands.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(500000.0, 500000.0)), - material: materials.add(Color::rgb(0.3, 0.5, 0.3)), + material: materials.add(LegacyColor::rgb(0.3, 0.5, 0.3)), ..default() }); diff --git a/examples/animation/animated_transform.rs b/examples/animation/animated_transform.rs index 3e177f0f701b81..084ac114a1f390 100644 --- a/examples/animation/animated_transform.rs +++ b/examples/animation/animated_transform.rs @@ -9,7 +9,7 @@ fn main() { App::new() .add_plugins(DefaultPlugins) .insert_resource(AmbientLight { - color: Color::WHITE, + color: LegacyColor::WHITE, brightness: 150.0, }) .add_systems(Startup, setup) @@ -125,7 +125,7 @@ fn setup( .spawn(( PbrBundle { mesh: meshes.add(Sphere::default()), - material: materials.add(Color::rgb(0.8, 0.7, 0.6)), + material: materials.add(LegacyColor::rgb(0.8, 0.7, 0.6)), ..default() }, // Add the animation player @@ -155,7 +155,7 @@ fn setup( PbrBundle { transform: Transform::from_xyz(1.5, 0.0, 0.0), mesh: meshes.add(Cuboid::new(0.5, 0.5, 0.5)), - material: materials.add(Color::rgb(0.3, 0.9, 0.3)), + material: materials.add(LegacyColor::rgb(0.3, 0.9, 0.3)), ..default() }, AnimationTarget { diff --git a/examples/animation/cubic_curve.rs b/examples/animation/cubic_curve.rs index b200b1e40ae5d0..c6eb26dc24537c 100644 --- a/examples/animation/cubic_curve.rs +++ b/examples/animation/cubic_curve.rs @@ -39,7 +39,7 @@ fn setup( commands.spawn(( PbrBundle { mesh: meshes.add(Cuboid::default()), - material: materials.add(Color::ORANGE), + material: materials.add(LegacyColor::ORANGE), transform: Transform::from_translation(points[0][0]), ..default() }, @@ -61,7 +61,7 @@ fn setup( // ground plane commands.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(50., 50.)), - material: materials.add(Color::SILVER), + material: materials.add(LegacyColor::SILVER), ..default() }); @@ -77,7 +77,7 @@ fn animate_cube(time: Res