Skip to content

Commit

Permalink
Rename Color to LegacyColor (#240)
Browse files Browse the repository at this point in the history
* Rename usages of `Color` to `LegacyColor`

* Fix tests
  • Loading branch information
Nilirad committed Feb 26, 2024
1 parent 68fd028 commit 6918ca1
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions examples/dynamic_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,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 = Color::hsl(hue as f32, 1.0, 0.5);
fill_mode.color = LegacyColor::hsl(hue as f32, 1.0, 0.5);
stroke_mode.options.line_width = outline_width as f32;
}
}
Expand Down Expand Up @@ -63,8 +63,8 @@ fn setup_system(mut commands: Commands) {
path: GeometryBuilder::build_as(&shape),
..default()
},
Fill::color(Color::CYAN),
Stroke::new(Color::BLACK, 10.0),
Fill::color(LegacyColor::CYAN),
Stroke::new(LegacyColor::BLACK, 10.0),
ExampleShape,
));
}
4 changes: 2 additions & 2 deletions examples/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn setup_system(mut commands: Commands) {
},
..default()
},
Stroke::new(Color::BLACK, 10.0),
Fill::color(Color::RED),
Stroke::new(LegacyColor::BLACK, 10.0),
Fill::color(LegacyColor::RED),
));
}
4 changes: 2 additions & 2 deletions examples/readme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn setup_system(mut commands: Commands) {
path: GeometryBuilder::build_as(&shape),
..default()
},
Fill::color(Color::CYAN),
Stroke::new(Color::BLACK, 10.0),
Fill::color(LegacyColor::CYAN),
Stroke::new(LegacyColor::BLACK, 10.0),
));
}
2 changes: 1 addition & 1 deletion examples/rounded_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ fn setup_system(mut commands: Commands) {
path: GeometryBuilder::build_as(&shape),
..default()
},
Fill::color(Color::CYAN),
Fill::color(LegacyColor::CYAN),
));
}
8 changes: 4 additions & 4 deletions examples/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn setup_system(mut commands: Commands) {
}),
..default()
},
Stroke::new(Color::BLACK, 4.0),
Stroke::new(LegacyColor::BLACK, 4.0),
));
parent.spawn((
ShapeBundle {
Expand All @@ -53,7 +53,7 @@ fn setup_system(mut commands: Commands) {
}),
..default()
},
Stroke::new(Color::BLACK, 2.5),
Stroke::new(LegacyColor::BLACK, 2.5),
));
});

Expand Down Expand Up @@ -84,7 +84,7 @@ fn setup_system(mut commands: Commands) {
}),
..default()
},
Stroke::new(Color::BLACK, 20.0),
Stroke::new(LegacyColor::BLACK, 20.0),
));

// shack walls
Expand All @@ -96,7 +96,7 @@ fn setup_system(mut commands: Commands) {
}),
..default()
},
Stroke::new(Color::BLACK, 17.5),
Stroke::new(LegacyColor::BLACK, 17.5),
));
});
}
Expand Down
18 changes: 9 additions & 9 deletions src/draw.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Types for defining shape color and options.

use bevy::{ecs::component::Component, render::color::Color};
use bevy::{ecs::component::Component, render::color::LegacyColor};
use lyon_tessellation::{FillOptions, StrokeOptions};

/// Defines the fill options for the lyon tessellator and color of the generated
Expand All @@ -9,13 +9,13 @@ use lyon_tessellation::{FillOptions, StrokeOptions};
#[derive(Component, Debug, Clone, Copy, PartialEq)]
pub struct Fill {
pub options: FillOptions,
pub color: Color,
pub color: LegacyColor,
}

impl Fill {
/// Convenience constructor requiring only the `Color`.
/// Convenience constructor requiring only the `LegacyColor`.
#[must_use]
pub fn color(color: Color) -> Self {
pub fn color(color: LegacyColor) -> Self {
Self {
options: FillOptions::default(),
color,
Expand All @@ -29,22 +29,22 @@ impl Fill {
#[derive(Component, Debug, Clone, Copy, PartialEq)]
pub struct Stroke {
pub options: StrokeOptions,
pub color: Color,
pub color: LegacyColor,
}

impl Stroke {
/// Constructor that requires a `Color` and a line width.
/// Constructor that requires a `LegacyColor` and a line width.
#[must_use]
pub fn new(color: Color, line_width: f32) -> Self {
pub fn new(color: LegacyColor, line_width: f32) -> Self {
Self {
options: StrokeOptions::default().with_line_width(line_width),
color,
}
}

/// Convenience constructor requiring only the `Color`.
/// Convenience constructor requiring only the `LegacyColor`.
#[must_use]
pub fn color(color: Color) -> Self {
pub fn color(color: LegacyColor) -> Self {
Self {
options: StrokeOptions::default(),
color,
Expand Down
6 changes: 3 additions & 3 deletions src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ impl GeometryBuilder {
/// path: builder.build(),
/// ..default()
/// },
/// Fill::color(Color::ORANGE_RED),
/// Stroke::new(Color::ORANGE_RED, 10.0),
/// Fill::color(LegacyColor::ORANGE_RED),
/// Stroke::new(LegacyColor::ORANGE_RED, 10.0),
/// ));
/// }
/// # bevy::ecs::system::assert_is_system(my_system);
Expand Down Expand Up @@ -115,7 +115,7 @@ impl GeometryBuilder {
/// path: GeometryBuilder::build_as(&line),
/// ..default()
/// },
/// Fill::color(Color::ORANGE_RED),
/// Fill::color(LegacyColor::ORANGE_RED),
/// ));
/// }
/// # bevy::ecs::system::assert_is_system(my_system);
Expand Down
4 changes: 2 additions & 2 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Plugin for ShapePlugin {
app.world.resource_mut::<Assets<ColorMaterial>>().insert(
COLOR_MATERIAL_HANDLE,
ColorMaterial {
color: Color::WHITE,
color: LegacyColor::WHITE,
..default()
},
);
Expand Down Expand Up @@ -85,7 +85,7 @@ fn mesh_shapes_system(
fill(
&mut fill_tess,
&path.0,
&Fill::color(Color::FUCHSIA),
&Fill::color(LegacyColor::FUCHSIA),
&mut buffers,
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/vertex.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::render::color::Color;
use bevy::render::color::LegacyColor;
use lyon_tessellation::{
self as tess, FillVertex, FillVertexConstructor, StrokeVertex, StrokeVertexConstructor,
};
Expand All @@ -19,7 +19,7 @@ pub struct Vertex {
/// Zero-sized type used to implement various vertex construction traits from
/// Lyon.
pub struct VertexConstructor {
pub color: Color,
pub color: LegacyColor,
}

/// Enables the construction of a [`Vertex`] when using a `FillTessellator`.
Expand Down

0 comments on commit 6918ca1

Please sign in to comment.