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 <alice.i.cecil@gmail.com>
This commit is contained in:
Alice Cecile 2024-02-24 16:35:32 -05:00 committed by GitHub
parent 10aef141f3
commit de004da8d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
171 changed files with 1209 additions and 1165 deletions

View file

@ -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.

View file

@ -136,9 +136,9 @@ impl From<Srgba> for Hsla {
}
}
impl From<Hsla> for bevy_render::color::Color {
impl From<Hsla> 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<Hsla> for bevy_render::color::Color {
}
}
impl From<bevy_render::color::Color> for Hsla {
fn from(value: bevy_render::color::Color) -> Self {
impl From<bevy_render::color::LegacyColor> 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,

View file

@ -157,9 +157,9 @@ impl From<Lcha> for LinearRgba {
}
}
impl From<Lcha> for bevy_render::color::Color {
impl From<Lcha> 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<Lcha> for bevy_render::color::Color {
}
}
impl From<bevy_render::color::Color> for Lcha {
fn from(value: bevy_render::color::Color) -> Self {
impl From<bevy_render::color::LegacyColor> 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,

View file

@ -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

View file

@ -172,9 +172,9 @@ impl From<Srgba> for LinearRgba {
}
}
impl From<LinearRgba> for bevy_render::color::Color {
impl From<LinearRgba> 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<LinearRgba> for bevy_render::color::Color {
}
}
impl From<bevy_render::color::Color> for LinearRgba {
fn from(value: bevy_render::color::Color) -> Self {
impl From<bevy_render::color::LegacyColor> 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,

View file

@ -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

View file

@ -267,9 +267,9 @@ impl From<Oklaba> for Srgba {
}
}
impl From<Srgba> for bevy_render::color::Color {
impl From<Srgba> 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<Srgba> for bevy_render::color::Color {
}
}
impl From<bevy_render::color::Color> for Srgba {
fn from(value: bevy_render::color::Color) -> Self {
impl From<bevy_render::color::LegacyColor> 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,

View file

@ -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<Xyza> for Oklaba {
}
}
impl From<Color> for Xyza {
fn from(value: Color) -> Self {
impl From<LegacyColor> for Xyza {
fn from(value: LegacyColor) -> Self {
LinearRgba::from(value).into()
}
}
impl From<Xyza> for Color {
impl From<Xyza> for LegacyColor {
fn from(value: Xyza) -> Self {
LinearRgba::from(value).into()
}

View file

@ -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);
}

View file

@ -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,
});
}

View file

@ -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,
},
})],

View file

@ -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<Color>,
pub default_color: Option<LegacyColor>,
}
/// 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<Color>,
pub color: Option<LegacyColor>,
}
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 {

View file

@ -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<usize>,
}
@ -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<usize>,
}

View file

@ -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<T: GizmoConfigGroup> 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)
}

View file

@ -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,
}

View file

@ -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<Item = Vec3>, color: Color) {
pub fn linestrip(&mut self, positions: impl IntoIterator<Item = Vec3>, 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<Item = (Vec3, Color)>) {
pub fn linestrip_gradient(&mut self, points: impl IntoIterator<Item = (Vec3, LegacyColor)>) {
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<Item = Vec2>, color: Color) {
pub fn linestrip_2d(&mut self, positions: impl IntoIterator<Item = Vec2>, 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<Item = (Vec2, Color)>) {
pub fn linestrip_gradient_2d(
&mut self,
positions: impl IntoIterator<Item = (Vec2, LegacyColor)>,
) {
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<Item = Color>) {
fn extend_list_colors(&mut self, colors: impl IntoIterator<Item = LegacyColor>) {
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,
}

View file

@ -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);
//! ```

View file

@ -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<P: Primitive2d> {
primitive: P,
position: Vec2,
angle: f32,
color: Color,
color: LegacyColor,
) -> Self::Output<'_>;
}
@ -46,7 +46,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<Direction2d> 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<Circle> 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<Ellipse> 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<Capsule2d> 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<Line2d> 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<Plane2d> 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<Segment2d> 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<Polyline2d<N>
primitive: Polyline2d<N>,
position: Vec2,
angle: f32,
color: Color,
color: LegacyColor,
) -> Self::Output<'_> {
if !self.enabled {
return;
@ -381,7 +381,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<BoxedPolyline2d> 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<Triangle2d> 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<Rectangle> 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<Polygon<N>>
primitive: Polygon<N>,
position: Vec2,
angle: f32,
color: Color,
color: LegacyColor,
) -> Self::Output<'_> {
if !self.enabled {
return;
@ -496,7 +496,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<BoxedPolygon> 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<RegularPolygon> for Gizmos<'w
primitive: RegularPolygon,
position: Vec2,
angle: f32,
color: Color,
color: LegacyColor,
) -> Self::Output<'_> {
if !self.enabled {
return;

View file

@ -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<P: Primitive3d> {
primitive: P,
position: Vec3,
rotation: Quat,
color: Color,
color: LegacyColor,
) -> Self::Output<'_>;
}
@ -43,7 +43,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<Direction3d> 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<Sphere> 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<Plane3d> 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<Line3d> 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<Segment3d> 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<Polyline3d<N>
primitive: Polyline3d<N>,
position: Vec3,
rotation: Quat,
color: Color,
color: LegacyColor,
) -> Self::Output<'_> {
if !self.enabled {
return;
@ -328,7 +328,7 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive3d<BoxedPolyline3d> 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<Cuboid> 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<Cylinder> 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<Capsule3d> 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<Cone> 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<ConicalFrustum> 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<Torus> for Gizmos<'w, 's, T>
primitive: Torus,
position: Vec3,
rotation: Quat,
color: Color,
color: LegacyColor,
) -> Self::Output<'_> {
Torus3dBuilder {
gizmos: self,

View file

@ -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<T: GizmoConfigGroup>(
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<T: GizmoConfigGroup>(
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<T: GizmoConfigGroup>(
half_height: f32,
rotation: Quat,
center: Vec3,
color: Color,
color: LegacyColor,
) {
circle_coordinates(radius, segments)
.map(move |point_2d| {

View file

@ -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

View file

@ -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);
//! ```

View file

@ -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,
}
}

View file

@ -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::<Assets<StandardMaterial>>().insert(
Handle::<StandardMaterial>::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()
},

View file

@ -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,
};
}

View file

@ -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<Assets<CustomMaterial>>, asset_server: Res<AssetServer>) {
/// commands.spawn(MaterialMeshBundle {
/// material: materials.add(CustomMaterial {
/// color: Color::RED,
/// color: LegacyColor::RED,
/// color_texture: asset_server.load("some_image.png"),
/// }),
/// ..Default::default()

View file

@ -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
/// <https://google.github.io/filament/Material%20Properties.pdf>.
///
/// 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<Color> for StandardMaterial {
fn from(color: Color) -> Self {
impl From<LegacyColor> for StandardMaterial {
fn from(color: LegacyColor) -> Self {
StandardMaterial {
base_color: color,
alpha_mode: if color.a() < 1.0 {

View file

@ -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,

View file

@ -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 {

View file

@ -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<Color> for ClearColorConfig {
fn from(color: Color) -> Self {
impl From<LegacyColor> for ClearColorConfig {
fn from(color: LegacyColor) -> Self {
Self::Custom(color)
}
}
@ -31,11 +31,11 @@ impl From<Color> 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))
}
}

File diff suppressed because it is too large Load diff

View file

@ -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::<alpha::AlphaMode>()
.register_type::<color::Color>()
.register_type::<color::LegacyColor>()
.register_type::<primitives::Aabb>()
.register_type::<primitives::CascadesFrusta>()
.register_type::<primitives::CubemapFrusta>()

View file

@ -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));
}

View file

@ -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<Image>,
@ -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<Image>`](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<Handle<Image>>`] 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<Handle<Image>>,
@ -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,
/// }
///

View file

@ -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<CachedTexture>,
clear_color: Option<Color>,
clear_color: Option<LegacyColor>,
is_first_call: Arc<AtomicBool>,
}
@ -21,7 +21,7 @@ impl ColorAttachment {
pub fn new(
texture: CachedTexture,
resolve_target: Option<CachedTexture>,
clear_color: Option<Color>,
clear_color: Option<LegacyColor>,
) -> Self {
Self {
texture,

View file

@ -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<Shader> =
@ -28,7 +29,7 @@ impl Plugin for ColorMaterialPlugin {
app.world.resource_mut::<Assets<ColorMaterial>>().insert(
Handle::<ColorMaterial>::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<Handle<Image>>,
@ -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<Color> for ColorMaterial {
fn from(color: Color) -> Self {
impl From<LegacyColor> for ColorMaterial {
fn from(color: LegacyColor) -> Self {
ColorMaterial {
color,
..Default::default()

View file

@ -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<Assets<CustomMaterial>>, asset_server: Res<AssetServer>) {
/// commands.spawn(MaterialMesh2dBundle {
/// material: materials.add(CustomMaterial {
/// color: Color::RED,
/// color: LegacyColor::RED,
/// color_texture: asset_server.load("some_image.png"),
/// }),
/// ..Default::default()

View file

@ -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<Rect>,
/// 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,

View file

@ -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

View file

@ -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<Font> = 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<Font> = 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,
}
}
}

View file

@ -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,

View file

@ -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(),

View file

@ -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<Image>,
pub atlas_size: Option<Vec2>,
@ -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,

View file

@ -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()

View file

@ -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<Color> for BackgroundColor {
fn from(color: Color) -> Self {
impl From<LegacyColor> for BackgroundColor {
fn from(color: LegacyColor) -> Self {
Self(color)
}
}
@ -1623,16 +1623,16 @@ impl From<Color> for BackgroundColor {
derive(serde::Serialize, serde::Deserialize),
reflect(Serialize, Deserialize)
)]
pub struct BorderColor(pub Color);
pub struct BorderColor(pub LegacyColor);
impl From<Color> for BorderColor {
fn from(color: Color) -> Self {
impl From<LegacyColor> 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<Interaction>>,
@ -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,

View file

@ -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()
});

View file

@ -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,

View file

@ -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) {

View file

@ -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()
},
)

View file

@ -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 {

View file

@ -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((

View file

@ -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()
});
}

View file

@ -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<u32> = vec![Color::BLACK.as_linear_rgba_u32()];
v_color.extend_from_slice(&[Color::YELLOW.as_linear_rgba_u32(); 10]);
let mut v_color: Vec<u32> = 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,

View file

@ -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);

View file

@ -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,

View file

@ -114,7 +114,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let style = TextStyle {
font: font.clone(),
font_size: 16.0,
color: Color::WHITE,
color: LegacyColor::WHITE,
};
// Load textures

View file

@ -36,7 +36,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
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<AssetServer>) {
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<AssetServer>) {
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<AssetServer>) {
});
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 {

View file

@ -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

View file

@ -22,7 +22,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
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<AssetServer>) {
});
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,

View file

@ -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()
});

View file

@ -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()
});

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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()

View file

@ -36,7 +36,7 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
asset_server: Res<AssetServer>,
) {
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(

View file

@ -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()
},
)

View file

@ -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()

View file

@ -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 {

View file

@ -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<Assets<StandardMaterial>>,
) {
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()

View file

@ -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::<AppStatus>()
.init_resource::<ExampleAssets>()
.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::<Assets<StandardMaterial>>();
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(),

View file

@ -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()

View file

@ -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;
}

View file

@ -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 {

View file

@ -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()
});

View file

@ -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()

View file

@ -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()
});

View file

@ -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()
},
)

View file

@ -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,
},
)
}

View file

@ -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))

View file

@ -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| {

View file

@ -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()
},

View file

@ -88,7 +88,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// 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,
});

View file

@ -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()

View file

@ -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()
},
))

View file

@ -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,

View file

@ -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()

View file

@ -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,

View file

@ -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()
},
)

View file

@ -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()
};

View file

@ -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()
});

View file

@ -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()
});

View file

@ -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()
});

View file

@ -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
};
}
}

View file

@ -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()
});

View file

@ -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 {

View file

@ -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<Time>, mut query: Query<(&mut Transform, &Curve)>, mut
for (mut transform, cubic_curve) in &mut query {
// Draw the curve
gizmos.linestrip(cubic_curve.0.iter_positions(50), Color::WHITE);
gizmos.linestrip(cubic_curve.0.iter_positions(50), LegacyColor::WHITE);
// position takes a point from the curve where 0 is the initial point
// and 1 is the last point
transform.translation = cubic_curve.0.position(t);

View file

@ -147,7 +147,7 @@ fn setup(
commands.spawn((
PbrBundle {
mesh: mesh.clone(),
material: materials.add(Color::rgb(
material: materials.add(LegacyColor::rgb(
rng.gen_range(0.0..1.0),
rng.gen_range(0.0..1.0),
rng.gen_range(0.0..1.0),

View file

@ -53,7 +53,7 @@ fn setup(
// You can also add assets directly to their Assets<T> storage:
let 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()
});

View file

@ -38,7 +38,7 @@ fn add_assets(
let box_mesh_handle = meshes.add(Cuboid::new(0.25, 0.25, 0.25));
commands.insert_resource(BoxMeshHandle(box_mesh_handle));
let box_material_handle = materials.add(Color::rgb(1.0, 0.2, 0.3));
let box_material_handle = materials.add(LegacyColor::rgb(1.0, 0.2, 0.3));
commands.insert_resource(BoxMaterialHandle(box_material_handle));
}

Some files were not shown because too many files have changed in this diff Show more