Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use lyon_path::Build trait for building paths instead of ReadyShapeBuilderTrait #268

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions src/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Types for defining and using geometries.

use lyon_algorithms::path::{builder::WithSvg, BuilderImpl};
use lyon_algorithms::path::{builder::WithSvg, traits::Build, BuilderImpl};
use lyon_tessellation::path::path::Builder;

use crate::{
Expand Down Expand Up @@ -144,21 +144,12 @@ impl<GenericBuilder> ShapeBuilderBase<GenericBuilder> for ReadyShapeBuilder<Gene
}
}

/// Generalizes the implementation of the `build` method
/// over multiple Lyon builders.
pub trait ReadyShapeBuilderTrait {
/// Builds a `Shape` according to the builder's settings.
fn build(self) -> Shape;
}

impl ReadyShapeBuilderTrait for ReadyShapeBuilder<Builder> {
fn build(self) -> Shape {
Shape::new(self.builder.build(), self.fill, self.stroke)
}
}

impl ReadyShapeBuilderTrait for ReadyShapeBuilder<WithSvg<BuilderImpl>> {
fn build(self) -> Shape {
impl<GenericBuilder> ReadyShapeBuilder<GenericBuilder>
where
GenericBuilder: Build<PathType = lyon_tessellation::path::Path>,
{
/// Builds the path according to builder settings.
pub fn build(self) -> Shape {
Shape::new(self.builder.build(), self.fill, self.stroke)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub mod prelude {
pub use crate::{
draw::{Fill, Stroke},
entity::Shape,
geometry::{Geometry, ReadyShapeBuilderTrait, ShapeBuilder, ShapeBuilderBase},
geometry::{Geometry, ShapeBuilder, ShapeBuilderBase},
path::ShapePath,
plugin::ShapePlugin,
shapes::{self, BorderRadii, RectangleOrigin, RegularPolygon, RegularPolygonFeature},
Expand Down
Loading