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:
isiko
2023-08-08 18:44:14 +02:00
committed by GitHub
parent f57fa2e7c9
commit 77e5ec9d4f
4 changed files with 23 additions and 1 deletions

View File

@@ -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]),
)])
}