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

First cut at stroke expansion #286

Merged
merged 9 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ features = ["mint", "schemars", "serde"]
default = ["std"]
std = []

[dependencies]
smallvec = "1.10"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think tinyvec would be better if possible since it has no unsafe code.


[dependencies.arrayvec]
version = "0.7.1"
default-features = false
Expand Down
11 changes: 11 additions & 0 deletions src/bezpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,17 @@ impl PathEl {
PathEl::ClosePath => false,
}
}

/// Get the end point of the path element, if it exists.
pub fn end_point(&self) -> Option<Point> {
match self {
PathEl::MoveTo(p) => Some(*p),
PathEl::LineTo(p1) => Some(*p1),
PathEl::QuadTo(_, p2) => Some(*p2),
PathEl::CurveTo(_, _, p3) => Some(*p3),
_ => None,
}
}
}

/// Implements [`Shape`] for a slice of [`PathEl`], provided that the first element of the slice is
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ mod rounded_rect_radii;
mod shape;
pub mod simplify;
mod size;
mod stroke;
#[cfg(feature = "std")]
mod svg;
mod translate_scale;
Expand All @@ -130,6 +131,7 @@ pub use crate::rounded_rect::*;
pub use crate::rounded_rect_radii::*;
pub use crate::shape::*;
pub use crate::size::*;
pub use crate::stroke::*;
#[cfg(feature = "std")]
pub use crate::svg::*;
pub use crate::translate_scale::*;
Expand Down
Loading
Loading