mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 07:18:12 +08:00
Implement function to find intersections between a Bezier and a linear line (#708)
* Implement line intersection for quadratics, begin work for cubic * Implement line intersection for cubic beziers, add tests for cubic root finding * Rename function and update comments * Minor refactor and adjust comments * Address PR comments
This commit is contained in:
committed by
Keavon Chambers
parent
a6c91204d6
commit
3c2fff4465
@@ -107,4 +107,13 @@ impl WasmBezier {
|
||||
let local_extrema = self.0.local_extrema();
|
||||
JsValue::from_serde(&serde_json::to_string(&local_extrema).unwrap()).unwrap()
|
||||
}
|
||||
|
||||
pub fn rotate(&self, angle: f64) -> WasmBezier {
|
||||
WasmBezier(self.0.rotate(angle))
|
||||
}
|
||||
|
||||
pub fn line_intersection(&self, js_points: &JsValue) -> Vec<JsValue> {
|
||||
let line: [DVec2; 2] = js_points.into_serde().unwrap();
|
||||
self.0.line_intersection(line).iter().map(|&p| vec_to_point(&p)).collect::<Vec<JsValue>>()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user