New node: Bevel (#2067)

* Bevel node

* Fix clippy lints

* Prevent negative values

* Rename flipped() -> reversed()

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
James Lindsay
2024-10-25 19:25:41 -07:00
committed by GitHub
co-authored by Keavon Chambers
parent 63d44f22e3
commit dae6b2f239
5 changed files with 243 additions and 7 deletions
+5 -2
View File
@@ -201,8 +201,11 @@ impl Bezier {
/// Returns true if the corresponding points of the two `Bezier`s are within the provided absolute value difference from each other.
/// The points considered includes the start, end, and any relevant handles.
pub fn abs_diff_eq(&self, other: &Bezier, max_abs_diff: f64) -> bool {
let self_points = self.get_points().collect::<Vec<DVec2>>();
let other_points = other.get_points().collect::<Vec<DVec2>>();
let a = if self.is_linear() { Self::from_linear_dvec2(self.start, self.end) } else { *self };
let b = if other.is_linear() { Self::from_linear_dvec2(other.start, other.end) } else { *other };
let self_points = a.get_points().collect::<Vec<DVec2>>();
let other_points = b.get_points().collect::<Vec<DVec2>>();
self_points.len() == other_points.len() && self_points.into_iter().zip(other_points).all(|(a, b)| a.abs_diff_eq(b, max_abs_diff))
}