Skip to content

Commit

Permalink
update to bevy 0.14.0-rc.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Azorlogh committed Jun 20, 2024
1 parent 0351fbd commit 445905b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 36 deletions.
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ version = "0.11.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 = { version = "0.14.0-rc.3", default-features = false, features = [
"bevy_sprite",
"bevy_render",
"bevy_core_pipeline",
Expand All @@ -24,7 +24,10 @@ lyon_algorithms = "1"
svgtypes = "0.12"

[dev-dependencies]
bevy = { version = "0.13", default-features = false, features = [
bevy = { version = "0.14.0-rc.3", default-features = false, features = [
"x11",
"bevy_asset",
"ktx2",
"zstd",
"bevy_pbr",
] }
6 changes: 3 additions & 3 deletions examples/dynamic_shape.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::f64::consts::PI;

use bevy::prelude::*;
use bevy::{color::palettes::basic::*, prelude::*};
use bevy_prototype_lyon::prelude::*;

fn main() {
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(AQUA),
Stroke::new(BLACK, 10.0),
ExampleShape,
));
}
6 changes: 3 additions & 3 deletions examples/path.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{color::palettes::basic::*, prelude::*};
use bevy_prototype_lyon::prelude::*;

fn main() {
Expand Down 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(BLACK, 10.0),
Fill::color(RED),
));
}
6 changes: 3 additions & 3 deletions examples/readme.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! 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::basic::*, prelude::*};
use bevy_prototype_lyon::prelude::*;

fn main() {
Expand All @@ -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(AQUA),
Stroke::new(BLACK, 10.0),
));
}
4 changes: 2 additions & 2 deletions examples/rounded_polygon.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{color::palettes::basic::*, prelude::*};
use bevy_prototype_lyon::prelude::*;

fn main() {
Expand Down Expand Up @@ -34,6 +34,6 @@ fn setup_system(mut commands: Commands) {
path: GeometryBuilder::build_as(&shape),
..default()
},
Fill::color(Color::CYAN),
Fill::color(AQUA),
));
}
14 changes: 7 additions & 7 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::{color::Color, ecs::component::Component};
use lyon_tessellation::{FillOptions, StrokeOptions};

/// Defines the fill options for the lyon tessellator and color of the generated
Expand All @@ -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<Color>) -> Self {
Self {
options: FillOptions::default(),
color,
color: color.into(),
}
}
}
Expand All @@ -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<Color>, 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<Color>) -> Self {
Self {
options: StrokeOptions::default(),
color,
color: color.into(),
}
}
}
24 changes: 11 additions & 13 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//! `ShapeBundle`.

use bevy::{
color::palettes::css::FUCHSIA,
prelude::*,
render::{mesh::Indices, render_asset::RenderAssetUsages, render_resource::PrimitiveTopology},
sprite::Mesh2dHandle,
Expand Down Expand Up @@ -43,13 +44,15 @@ impl Plugin for ShapePlugin {
)
.add_systems(PostUpdate, mesh_shapes_system.in_set(BuildShapes));

app.world.resource_mut::<Assets<ColorMaterial>>().insert(
COLOR_MATERIAL_HANDLE,
ColorMaterial {
color: Color::WHITE,
..default()
},
);
app.world_mut()
.resource_mut::<Assets<ColorMaterial>>()
.insert(
&COLOR_MATERIAL_HANDLE,
ColorMaterial {
color: Color::WHITE,
..default()
},
);
}
}

Expand Down Expand Up @@ -82,12 +85,7 @@ fn mesh_shapes_system(
}

if (maybe_fill_mode, maybe_stroke_mode) == (None, None) {
fill(
&mut fill_tess,
&path.0,
&Fill::color(Color::FUCHSIA),
&mut buffers,
);
fill(&mut fill_tess, &path.0, &Fill::color(FUCHSIA), &mut buffers);
}

mesh.0 = meshes.add(build_mesh(&buffers));
Expand Down
6 changes: 3 additions & 3 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::color::{Color, ColorToComponents};
use lyon_tessellation::{
self as tess, FillVertex, FillVertexConstructor, StrokeVertex, StrokeVertexConstructor,
};
Expand Down Expand Up @@ -27,7 +27,7 @@ impl FillVertexConstructor<Vertex> 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(),
}
}
}
Expand All @@ -37,7 +37,7 @@ impl StrokeVertexConstructor<Vertex> 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(),
}
}
}

0 comments on commit 445905b

Please sign in to comment.