From f4d16abe42970d4bcd6393a0965a589bb35d4d4f Mon Sep 17 00:00:00 2001 From: Federico Rinaldi Date: Fri, 1 Mar 2024 18:28:11 +0100 Subject: [PATCH] Revert "Rename `Color` to `LegacyColor` (#240)" (#243) This reverts commit 6918ca18cdfc6843be7616fedc47487d31fb8731. --- examples/dynamic_shape.rs | 6 +++--- examples/path.rs | 4 ++-- examples/readme.rs | 4 ++-- examples/rounded_polygon.rs | 2 +- examples/svg.rs | 8 ++++---- src/draw.rs | 18 +++++++++--------- src/geometry.rs | 6 +++--- src/plugin.rs | 4 ++-- src/vertex.rs | 4 ++-- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/examples/dynamic_shape.rs b/examples/dynamic_shape.rs index d74315d..eef3285 100644 --- a/examples/dynamic_shape.rs +++ b/examples/dynamic_shape.rs @@ -30,7 +30,7 @@ fn change_draw_mode_system(mut query: Query<(&mut Fill, &mut Stroke)>, time: Res let outline_width = 2.0 + time.elapsed_seconds_f64().sin().abs() * 10.0; for (mut fill_mode, mut stroke_mode) in query.iter_mut() { - fill_mode.color = LegacyColor::hsl(hue as f32, 1.0, 0.5); + fill_mode.color = Color::hsl(hue as f32, 1.0, 0.5); stroke_mode.options.line_width = outline_width as f32; } } @@ -62,8 +62,8 @@ fn setup_system(mut commands: Commands) { path: GeometryBuilder::build_as(&shape), ..default() }, - Fill::color(LegacyColor::CYAN), - Stroke::new(LegacyColor::BLACK, 10.0), + Fill::color(Color::CYAN), + Stroke::new(Color::BLACK, 10.0), ExampleShape, )); } diff --git a/examples/path.rs b/examples/path.rs index 9d0cb18..7b82e3b 100644 --- a/examples/path.rs +++ b/examples/path.rs @@ -35,7 +35,7 @@ fn setup_system(mut commands: Commands) { }, ..default() }, - Stroke::new(LegacyColor::BLACK, 10.0), - Fill::color(LegacyColor::RED), + Stroke::new(Color::BLACK, 10.0), + Fill::color(Color::RED), )); } diff --git a/examples/readme.rs b/examples/readme.rs index cc72c7a..14cbeba 100644 --- a/examples/readme.rs +++ b/examples/readme.rs @@ -25,7 +25,7 @@ fn setup_system(mut commands: Commands) { path: GeometryBuilder::build_as(&shape), ..default() }, - Fill::color(LegacyColor::CYAN), - Stroke::new(LegacyColor::BLACK, 10.0), + Fill::color(Color::CYAN), + Stroke::new(Color::BLACK, 10.0), )); } diff --git a/examples/rounded_polygon.rs b/examples/rounded_polygon.rs index 1866f5d..184fd5b 100644 --- a/examples/rounded_polygon.rs +++ b/examples/rounded_polygon.rs @@ -33,6 +33,6 @@ fn setup_system(mut commands: Commands) { path: GeometryBuilder::build_as(&shape), ..default() }, - Fill::color(LegacyColor::CYAN), + Fill::color(Color::CYAN), )); } diff --git a/examples/svg.rs b/examples/svg.rs index a82b112..6ecc472 100644 --- a/examples/svg.rs +++ b/examples/svg.rs @@ -42,7 +42,7 @@ fn setup_system(mut commands: Commands) { }), ..default() }, - Stroke::new(LegacyColor::BLACK, 4.0), + Stroke::new(Color::BLACK, 4.0), )); parent.spawn(( ShapeBundle { @@ -52,7 +52,7 @@ fn setup_system(mut commands: Commands) { }), ..default() }, - Stroke::new(LegacyColor::BLACK, 2.5), + Stroke::new(Color::BLACK, 2.5), )); }); @@ -83,7 +83,7 @@ fn setup_system(mut commands: Commands) { }), ..default() }, - Stroke::new(LegacyColor::BLACK, 20.0), + Stroke::new(Color::BLACK, 20.0), )); // shack walls @@ -95,7 +95,7 @@ fn setup_system(mut commands: Commands) { }), ..default() }, - Stroke::new(LegacyColor::BLACK, 17.5), + Stroke::new(Color::BLACK, 17.5), )); }); } diff --git a/src/draw.rs b/src/draw.rs index 4ed6ddb..d6d6c13 100644 --- a/src/draw.rs +++ b/src/draw.rs @@ -1,6 +1,6 @@ //! Types for defining shape color and options. -use bevy::{ecs::component::Component, render::color::LegacyColor}; +use bevy::{ecs::component::Component, render::color::Color}; use lyon_tessellation::{FillOptions, StrokeOptions}; /// Defines the fill options for the lyon tessellator and color of the generated @@ -9,13 +9,13 @@ use lyon_tessellation::{FillOptions, StrokeOptions}; #[derive(Component, Debug, Clone, Copy, PartialEq)] pub struct Fill { pub options: FillOptions, - pub color: LegacyColor, + pub color: Color, } impl Fill { - /// Convenience constructor requiring only the `LegacyColor`. + /// Convenience constructor requiring only the `Color`. #[must_use] - pub fn color(color: LegacyColor) -> Self { + pub fn color(color: Color) -> Self { Self { options: FillOptions::default(), color, @@ -29,22 +29,22 @@ impl Fill { #[derive(Component, Debug, Clone, Copy, PartialEq)] pub struct Stroke { pub options: StrokeOptions, - pub color: LegacyColor, + pub color: Color, } impl Stroke { - /// Constructor that requires a `LegacyColor` and a line width. + /// Constructor that requires a `Color` and a line width. #[must_use] - pub fn new(color: LegacyColor, line_width: f32) -> Self { + pub fn new(color: Color, line_width: f32) -> Self { Self { options: StrokeOptions::default().with_line_width(line_width), color, } } - /// Convenience constructor requiring only the `LegacyColor`. + /// Convenience constructor requiring only the `Color`. #[must_use] - pub fn color(color: LegacyColor) -> Self { + pub fn color(color: Color) -> Self { Self { options: StrokeOptions::default(), color, diff --git a/src/geometry.rs b/src/geometry.rs index 4daed4a..28930e1 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -80,8 +80,8 @@ impl GeometryBuilder { /// path: builder.build(), /// ..default() /// }, - /// Fill::color(LegacyColor::ORANGE_RED), - /// Stroke::new(LegacyColor::ORANGE_RED, 10.0), + /// Fill::color(Color::ORANGE_RED), + /// Stroke::new(Color::ORANGE_RED, 10.0), /// )); /// } /// # bevy::ecs::system::assert_is_system(my_system); @@ -115,7 +115,7 @@ impl GeometryBuilder { /// path: GeometryBuilder::build_as(&line), /// ..default() /// }, - /// Fill::color(LegacyColor::ORANGE_RED), + /// Fill::color(Color::ORANGE_RED), /// )); /// } /// # bevy::ecs::system::assert_is_system(my_system); diff --git a/src/plugin.rs b/src/plugin.rs index a95d2ce..badf210 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -46,7 +46,7 @@ impl Plugin for ShapePlugin { app.world.resource_mut::>().insert( COLOR_MATERIAL_HANDLE, ColorMaterial { - color: LegacyColor::WHITE, + color: Color::WHITE, ..default() }, ); @@ -85,7 +85,7 @@ fn mesh_shapes_system( fill( &mut fill_tess, &path.0, - &Fill::color(LegacyColor::FUCHSIA), + &Fill::color(Color::FUCHSIA), &mut buffers, ); } diff --git a/src/vertex.rs b/src/vertex.rs index 742fc32..4c9e178 100644 --- a/src/vertex.rs +++ b/src/vertex.rs @@ -1,4 +1,4 @@ -use bevy::render::color::LegacyColor; +use bevy::render::color::Color; use lyon_tessellation::{ self as tess, FillVertex, FillVertexConstructor, StrokeVertex, StrokeVertexConstructor, }; @@ -19,7 +19,7 @@ pub struct Vertex { /// Zero-sized type used to implement various vertex construction traits from /// Lyon. pub struct VertexConstructor { - pub color: LegacyColor, + pub color: Color, } /// Enables the construction of a [`Vertex`] when using a `FillTessellator`.