diff --git a/CHANGELOG.md b/CHANGELOG.md index 5094aa8..4ce313b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +1,16 @@ # Changelog -## 0.10.0 -- Support for Bevy 0.12. -- `ShapeBundle` now contains the `spatial: SpatialBundle` field, which bundles together `Transform`, `GlobalTransform`, `Visibility` and `InheritedVisibility`. - -## 0.9.0 -- Support for Bevy 0.11. +## 0.12.0 +- Support for Bevy 0.14. ## 0.11.0 -- Support for Bevy 0.13 +- Support for Bevy 0.13. ## 0.10.0 -- Support for Bevy 0.12 +- Support for Bevy 0.12. +- `ShapeBundle` now contains the `spatial: SpatialBundle` field, which bundles together `Transform`, `GlobalTransform`, `Visibility` and `InheritedVisibility`. ## 0.9.0 +- Support for Bevy 0.11. - `ShapeBundle` now contains the `spatial: SpatialBundle` field, which bundles together `Transform`, diff --git a/Cargo.toml b/Cargo.toml index 7a8fc44..173d2f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,23 +8,23 @@ license = "MIT OR Apache-2.0" name = "bevy_prototype_lyon" readme = "README.md" repository = "https://github.com/Nilirad/bevy_prototype_lyon/" -version = "0.11.0" +version = "0.12.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bevy = { version = "0.13", default-features = false, features = [ - "bevy_sprite", - "bevy_render", - "bevy_core_pipeline", - "bevy_asset", +bevy = { version = "0.14", default-features = false, features = [ + "bevy_sprite", + "bevy_render", + "bevy_core_pipeline", + "bevy_asset", ] } lyon_tessellation = "1" lyon_algorithms = "1" svgtypes = "0.12" [dev-dependencies] -bevy = { version = "0.13", default-features = false, features = [ - "x11", - "bevy_asset", +bevy = { version = "0.14", default-features = false, features = [ + "x11", + "bevy_asset", ] } diff --git a/README.md b/README.md index ab54b87..b3423fc 100644 --- a/README.md +++ b/README.md @@ -27,14 +27,13 @@ cargo add bevy_prototype_lyon Then, you can start by drawing simple shapes: ```rust -use bevy::prelude::*; +use bevy::{color::palettes::css::*, prelude::*}; use bevy_prototype_lyon::prelude::*; fn main() { App::new() .insert_resource(Msaa::Sample4) - .add_plugins(DefaultPlugins) - .add_plugins(ShapePlugin) + .add_plugins((DefaultPlugins, ShapePlugin)) .add_systems(Startup, setup_system) .run(); } @@ -52,8 +51,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(DARK_CYAN), + Stroke::new(BLACK, 10.0), )); } ``` @@ -68,6 +67,7 @@ The following table shows the latest version of `bevy_prototype_lyon` that suppo |bevy|bevy_prototype_lyon|license| |---|---|---| +|0.14|0.12|MIT/Apache 2.0| |0.13|0.11|MIT/Apache 2.0| |0.12|0.10|MIT/Apache 2.0| |0.11|0.9|MIT/Apache 2.0| diff --git a/examples/dynamic_shape.rs b/examples/dynamic_shape.rs index a10fd27..3e9b741 100644 --- a/examples/dynamic_shape.rs +++ b/examples/dynamic_shape.rs @@ -1,13 +1,12 @@ use std::f64::consts::PI; -use bevy::prelude::*; +use bevy::{color::palettes::css::*, prelude::*}; use bevy_prototype_lyon::prelude::*; fn main() { App::new() .insert_resource(Msaa::Sample4) - .add_plugins(DefaultPlugins) - .add_plugins(ShapePlugin) + .add_plugins((DefaultPlugins, ShapePlugin)) .add_systems(Startup, setup_system) .add_systems(Update, change_draw_mode_system) .add_systems(Update, change_number_of_sides) @@ -63,8 +62,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(DARK_CYAN), + Stroke::new(BLACK, 10.0), ExampleShape, )); } diff --git a/examples/path.rs b/examples/path.rs index 0b97c03..571396c 100644 --- a/examples/path.rs +++ b/examples/path.rs @@ -1,11 +1,10 @@ -use bevy::prelude::*; +use bevy::{color::palettes::css::*, prelude::*}; use bevy_prototype_lyon::prelude::*; fn main() { App::new() .insert_resource(Msaa::Sample4) - .add_plugins(DefaultPlugins) - .add_plugins(ShapePlugin) + .add_plugins((DefaultPlugins, ShapePlugin)) .add_systems(Startup, setup_system) .run(); } @@ -36,7 +35,7 @@ fn setup_system(mut commands: Commands) { }, ..default() }, - Stroke::new(Color::BLACK, 10.0), - Fill::color(Color::RED), + Stroke::new(BLACK, 10.0), + Fill::color(RED), )); } diff --git a/examples/readme.rs b/examples/readme.rs index dda0f71..a655b21 100644 --- a/examples/readme.rs +++ b/examples/readme.rs @@ -1,14 +1,13 @@ //! This is the example that goes to the README.md file. The README.md should be //! updated before every release. -use bevy::prelude::*; +use bevy::{color::palettes::css::*, prelude::*}; use bevy_prototype_lyon::prelude::*; fn main() { App::new() .insert_resource(Msaa::Sample4) - .add_plugins(DefaultPlugins) - .add_plugins(ShapePlugin) + .add_plugins((DefaultPlugins, ShapePlugin)) .add_systems(Startup, setup_system) .run(); } @@ -26,7 +25,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(DARK_CYAN), + Stroke::new(BLACK, 10.0), )); } diff --git a/examples/rounded_polygon.rs b/examples/rounded_polygon.rs index 3fc9d2c..5db2947 100644 --- a/examples/rounded_polygon.rs +++ b/examples/rounded_polygon.rs @@ -1,11 +1,10 @@ -use bevy::prelude::*; +use bevy::{color::palettes::css::*, prelude::*}; use bevy_prototype_lyon::prelude::*; fn main() { App::new() .insert_resource(Msaa::Sample4) - .add_plugins(DefaultPlugins) - .add_plugins(ShapePlugin) + .add_plugins((DefaultPlugins, ShapePlugin)) .add_systems(Startup, setup_system) .run(); } @@ -34,6 +33,6 @@ fn setup_system(mut commands: Commands) { path: GeometryBuilder::build_as(&shape), ..default() }, - Fill::color(Color::CYAN), + Fill::color(DARK_CYAN), )); } diff --git a/examples/svg.rs b/examples/svg.rs index 00dc6bb..6ecc472 100644 --- a/examples/svg.rs +++ b/examples/svg.rs @@ -5,8 +5,7 @@ fn main() { App::new() //Added msaa to reduce aliasing .insert_resource(Msaa::Sample4) - .add_plugins(DefaultPlugins) - .add_plugins(ShapePlugin) + .add_plugins((DefaultPlugins, ShapePlugin)) .add_systems(Startup, setup_system) .run(); } diff --git a/src/draw.rs b/src/draw.rs index d6d6c13..3b241fd 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::Color}; +use bevy::{color::Color, ecs::component::Component}; use lyon_tessellation::{FillOptions, StrokeOptions}; /// Defines the fill options for the lyon tessellator and color of the generated @@ -15,10 +15,10 @@ pub struct Fill { impl Fill { /// Convenience constructor requiring only the `Color`. #[must_use] - pub fn color(color: Color) -> Self { + pub fn color(color: impl Into) -> Self { Self { options: FillOptions::default(), - color, + color: color.into(), } } } @@ -35,19 +35,19 @@ pub struct Stroke { impl Stroke { /// Constructor that requires a `Color` and a line width. #[must_use] - pub fn new(color: Color, line_width: f32) -> Self { + pub fn new(color: impl Into, line_width: f32) -> Self { Self { options: StrokeOptions::default().with_line_width(line_width), - color, + color: color.into(), } } /// Convenience constructor requiring only the `Color`. #[must_use] - pub fn color(color: Color) -> Self { + pub fn color(color: impl Into) -> Self { Self { options: StrokeOptions::default(), - color, + color: color.into(), } } } diff --git a/src/geometry.rs b/src/geometry.rs index 28930e1..14a3e9f 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -66,6 +66,7 @@ impl GeometryBuilder { /// ``` /// # use bevy::prelude::*; /// # use bevy_prototype_lyon::prelude::*; + /// # use bevy::color::palettes; /// # /// fn my_system(mut commands: Commands) { /// let line = shapes::Line(Vec2::ZERO, Vec2::new(10.0, 0.0)); @@ -80,8 +81,8 @@ impl GeometryBuilder { /// path: builder.build(), /// ..default() /// }, - /// Fill::color(Color::ORANGE_RED), - /// Stroke::new(Color::ORANGE_RED, 10.0), + /// Fill::color(Color::Srgba(palettes::css::ORANGE_RED)), + /// Stroke::new(Color::Srgba(palettes::css::ORANGE_RED), 10.0), /// )); /// } /// # bevy::ecs::system::assert_is_system(my_system); @@ -107,6 +108,7 @@ impl GeometryBuilder { /// ``` /// # use bevy::prelude::*; /// # use bevy_prototype_lyon::prelude::*; + /// # use bevy::color::palettes; /// # /// fn my_system(mut commands: Commands) { /// let line = shapes::Line(Vec2::ZERO, Vec2::new(10.0, 0.0)); @@ -115,7 +117,7 @@ impl GeometryBuilder { /// path: GeometryBuilder::build_as(&line), /// ..default() /// }, - /// Fill::color(Color::ORANGE_RED), + /// Fill::color(Color::Srgba(palettes::css::ORANGE_RED)), /// )); /// } /// # bevy::ecs::system::assert_is_system(my_system); diff --git a/src/plugin.rs b/src/plugin.rs index badf210..09730f5 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -12,6 +12,7 @@ //! `ShapeBundle`. use bevy::{ + color::palettes, prelude::*, render::{mesh::Indices, render_asset::RenderAssetUsages, render_resource::PrimitiveTopology}, sprite::Mesh2dHandle, @@ -43,13 +44,15 @@ impl Plugin for ShapePlugin { ) .add_systems(PostUpdate, mesh_shapes_system.in_set(BuildShapes)); - app.world.resource_mut::>().insert( - COLOR_MATERIAL_HANDLE, - ColorMaterial { - color: Color::WHITE, - ..default() - }, - ); + app.world_mut() + .resource_mut::>() + .insert( + &COLOR_MATERIAL_HANDLE, + ColorMaterial { + color: Color::WHITE, + ..default() + }, + ); } } @@ -85,7 +88,7 @@ fn mesh_shapes_system( fill( &mut fill_tess, &path.0, - &Fill::color(Color::FUCHSIA), + &Fill::color(Color::Srgba(palettes::css::FUCHSIA)), &mut buffers, ); } diff --git a/src/shapes.rs b/src/shapes.rs index 69ee0b6..f435601 100644 --- a/src/shapes.rs +++ b/src/shapes.rs @@ -294,10 +294,10 @@ impl Geometry for Line { /// 1) Go to File>Document Properties>General>Display Units and set it to px /// /// 2) In File>Document Properties>Custom Size>Units set it to px, also, this -/// size would be used for `svg_doc_size_in_px` +/// size would be used for `svg_doc_size_in_px` /// /// 3) In File>Document Properties>Scale>Scale x make sure it is set to 1 User -/// unit per px +/// unit per px /// ///Example exists in the examples folder pub struct SvgPathShape { diff --git a/src/vertex.rs b/src/vertex.rs index 4c9e178..7cad78e 100644 --- a/src/vertex.rs +++ b/src/vertex.rs @@ -1,4 +1,4 @@ -use bevy::render::color::Color; +use bevy::color::{Color, ColorToComponents}; use lyon_tessellation::{ self as tess, FillVertex, FillVertexConstructor, StrokeVertex, StrokeVertexConstructor, }; @@ -27,7 +27,7 @@ impl FillVertexConstructor for VertexConstructor { fn new_vertex(&mut self, vertex: FillVertex) -> Vertex { Vertex { position: [vertex.position().x, vertex.position().y], - color: self.color.as_linear_rgba_f32(), + color: self.color.to_linear().to_f32_array(), } } } @@ -37,7 +37,7 @@ impl StrokeVertexConstructor for VertexConstructor { fn new_vertex(&mut self, vertex: StrokeVertex) -> Vertex { Vertex { position: [vertex.position().x, vertex.position().y], - color: self.color.as_linear_rgba_f32(), + color: self.color.to_linear().to_f32_array(), } } }