mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 06:38:03 +08:00
Add bounding box node (#1376)
* Add bounding box node Generates a rectangle based on the bounding box of the input vector data * Remove redundant <> * Fix formatting --------- Co-authored-by: Dennis Kobert <dennis@kobert.dev>
This commit is contained in:
@@ -133,3 +133,15 @@ fn circular_repeat_vector_data(mut vector_data: VectorData, rotation_offset: f32
|
||||
vector_data.subpaths = new_subpaths;
|
||||
vector_data
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct BoundingBoxNode;
|
||||
|
||||
#[node_macro::node_fn(BoundingBoxNode)]
|
||||
fn generate_bounding_box(mut vector_data: VectorData) -> VectorData {
|
||||
let bounding_box = vector_data.bounding_box().unwrap();
|
||||
VectorData::from_subpaths(vec![Subpath::new_rect(
|
||||
vector_data.transform.transform_point2(bounding_box[0]),
|
||||
vector_data.transform.transform_point2(bounding_box[1]),
|
||||
)])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user