mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 02:28:12 +08:00
Bezier-rs: Add calculations for area and centroid of subpaths (#1729)
* add code to calculate area and centroid of subpath * change library to poly_it * add a demo of area and centroid * modify algorithm to consider negetive area as positive * add code for manipulating polynomials in bezier-rs * remove `poly_it` dependency and use custom Polynomial * formatting floats to skip last zero * add debug mechanism * collect both intersection points instead of one * fix test and cargo fmt * apply minimum separation filtering in self_intersection and use better endpoint filtering algorithm * remove debug mechanism and cargo fmt * consider the subpath as closed for intersection calculation * add documentation for polynomial.rs * impl display for Polynomial * make area always positive * add missing docs * fix test and cargo fmt * Naming/formatting code review --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
e769f50877
commit
beb88d280c
@@ -29,6 +29,7 @@ unsafe impl<ManipulatorGroupId: crate::Identifier> dyn_any::StaticType for Subpa
|
||||
pub struct SubpathIter<'a, ManipulatorGroupId: crate::Identifier> {
|
||||
index: usize,
|
||||
subpath: &'a Subpath<ManipulatorGroupId>,
|
||||
is_always_closed: bool,
|
||||
}
|
||||
|
||||
impl<ManipulatorGroupId: crate::Identifier> Index<usize> for Subpath<ManipulatorGroupId> {
|
||||
@@ -55,8 +56,9 @@ impl<ManipulatorGroupId: crate::Identifier> Iterator for SubpathIter<'_, Manipul
|
||||
if self.subpath.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let closed = if self.is_always_closed { true } else { self.subpath.closed };
|
||||
let len = self.subpath.len() - 1
|
||||
+ match self.subpath.closed {
|
||||
+ match closed {
|
||||
true => 1,
|
||||
false => 0,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user