mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-04 12:28:12 +08:00
Implement function that projects to a Bezier curve (#688)
* UI section for the projection function * added bezier project impl * Fix project function and add test for it * Search method * Re-use comptued distances * Update comments * rebase project changes * clean up tests and library code * use built-in functions and destructure syntax * Remove redundant project implementation * Fix typo, add lut size as parameter and add constant * address comments Co-authored-by: Thomas Cheng <contact.chengthomas@gmail.com>
This commit is contained in:
co-authored by
Thomas Cheng
parent
3476d5a203
commit
4775a23c17
@@ -29,3 +29,11 @@ pub fn compute_abc_for_cubic_through_points(start_point: DVec2, point_on_curve:
|
||||
|
||||
compute_abc_through_points(start_point, point_on_curve, end_point, t_cubed, cubed_one_minus_t)
|
||||
}
|
||||
|
||||
pub fn get_closest_point_in_lut(lut: &[DVec2], point: DVec2) -> (i32, f64) {
|
||||
lut.iter()
|
||||
.enumerate()
|
||||
.map(|(i, p)| (i as i32, point.distance(*p)))
|
||||
.min_by(|x, y| (&(x.1)).partial_cmp(&(y.1)).unwrap())
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user