mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-11 07:00:55 +08:00
Add Area and Centroid nodes (#1749)
* initial attempt for area node * allow node preview for more types * make AreaNode sync and add CentroidNode * cargo fmt * preview of DVec2 * make the nodes async again * use segment domain instead of region domain * modify the check for linearity * create a limit for area in centroid calculation * cargo fmt * reverse unnecessary changes * add threshold to area calculation too. * handle zero area edge case * add todo comment * implement 1D centroid and use it as fallback * formatting floats to skip last zero * add Centroid Type radio button to Centroid Node * rename docs to use area and perimeter centroid * add web demos for perimeter centroid * add tests for perimeter centroid * add fallback to use average of points * Fix for broken area * missing fixes * Code review and rename Perimeter Centroid to Length Centroid * Use dummy footprint in Area and Centroid nodes * add doc and todo to clarify when `is_linear` fails * use epsilon instead of zero --------- Co-authored-by: 0hypercube <0hypercube@gmail.com> Co-authored-by: Keavon Chambers <keavon@keavon.com> Co-authored-by: Dennis Kobert <dennis@kobert.dev>
This commit is contained in:
co-authored by
0hypercube
Keavon Chambers
Dennis Kobert
parent
4587457bfa
commit
5a1c171fc3
@@ -148,6 +148,13 @@ impl WasmBezier {
|
||||
wrap_svg_tag(format!("{bezier}{}", draw_text(format!("Length: {:.2}", self.0.length(None)), TEXT_OFFSET_X, TEXT_OFFSET_Y, BLACK)))
|
||||
}
|
||||
|
||||
pub fn length_centroid(&self) -> String {
|
||||
let bezier = self.get_bezier_path();
|
||||
let centroid = self.0.length_centroid(None);
|
||||
let point_text = draw_circle(centroid, 4., RED, 1.5, WHITE);
|
||||
wrap_svg_tag(format!("{bezier}{}", point_text))
|
||||
}
|
||||
|
||||
pub fn evaluate(&self, raw_t: f64, t_variant: String) -> String {
|
||||
let bezier = self.get_bezier_path();
|
||||
let t = parse_t_variant(&t_variant, raw_t);
|
||||
|
||||
Reference in New Issue
Block a user