Bezier-rs: Add SubpathTValue and euclidean parameterization for subpaths (#1027)

* Added SubpathTValue and euclidean parameterization for subpaths

* Small fix

* Added bounds checking to get_segment

* Code review

* code review nit for clarity

---------

Co-authored-by: Hannah Li <hannahli2010@gmail.com>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Rob Nadal
2023-02-17 15:33:52 -05:00
committed by GitHub
co-authored by Hannah Li Keavon Chambers
parent 2291f7e7d6
commit f241ef3ff6
10 changed files with 334 additions and 247 deletions
@@ -1,3 +1,5 @@
use super::Bezier;
use glam::DVec2;
use std::fmt::{Debug, Formatter, Result};
@@ -22,3 +24,18 @@ impl Debug for ManipulatorGroup {
}
}
}
impl ManipulatorGroup {
pub fn to_bezier(&self, end_group: &ManipulatorGroup) -> Bezier {
let start = self.anchor;
let end = end_group.anchor;
let out_handle = self.out_handle;
let in_handle = end_group.in_handle;
match (out_handle, in_handle) {
(Some(handle1), Some(handle2)) => Bezier::from_cubic_dvec2(start, handle1, handle2, end),
(Some(handle), None) | (None, Some(handle)) => Bezier::from_quadratic_dvec2(start, handle, end),
(None, None) => Bezier::from_linear_dvec2(start, end),
}
}
}