mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-11 03:40:57 +08:00
Bezier-rs: add Tangents/Normals to Point functions (#1547)
* Add tangent/normal to point to bézier-rs * Add license information and general cleanup * Bump version * Add iframe demos --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
committed by
Keavon Chambers
co-authored by
Keavon Chambers
parent
c14c6fbe93
commit
6a10bcc3fc
@@ -300,6 +300,31 @@ impl WasmBezier {
|
||||
let content = format!("{bezier}{}", draw_line(projected_point.x, projected_point.y, x, y, RED, 1.),);
|
||||
wrap_svg_tag(content)
|
||||
}
|
||||
pub fn tangents_to_point(&self, x: f64, y: f64) -> String {
|
||||
let bezier = self.get_bezier_path();
|
||||
let mut content = String::new();
|
||||
for t in self.0.tangents_to_point(DVec2::new(x, y)) {
|
||||
let point = self.0.evaluate(TValue::Parametric(t));
|
||||
content += &draw_line(x, y, point.x, point.y, RED, 1.);
|
||||
}
|
||||
use std::fmt::Write;
|
||||
write!(content, "{bezier}").unwrap();
|
||||
|
||||
wrap_svg_tag(content)
|
||||
}
|
||||
|
||||
pub fn normals_to_point(&self, x: f64, y: f64) -> String {
|
||||
let bezier = self.get_bezier_path();
|
||||
let mut content = String::new();
|
||||
for t in self.0.normals_to_point(DVec2::new(x, y)) {
|
||||
let point = self.0.evaluate(TValue::Parametric(t));
|
||||
content += &draw_line(x, y, point.x, point.y, RED, 1.);
|
||||
}
|
||||
use std::fmt::Write;
|
||||
write!(content, "{bezier}").unwrap();
|
||||
|
||||
wrap_svg_tag(content)
|
||||
}
|
||||
|
||||
pub fn local_extrema(&self) -> String {
|
||||
let local_extrema: [Vec<f64>; 2] = self.0.local_extrema();
|
||||
|
||||
Reference in New Issue
Block a user