Skip to content

Commit

Permalink
Merge pull request #286 from linebender/stroke
Browse files Browse the repository at this point in the history
First cut at stroke expansion
  • Loading branch information
raphlinus committed Jun 27, 2023
2 parents f8ba01e + 063839e commit aa999f7
Show file tree
Hide file tree
Showing 4 changed files with 692 additions and 0 deletions.
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"

[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

0 comments on commit aa999f7

Please sign in to comment.