Skip to content

Commit a94354d

Browse files
kythyriaKeavon
andauthored
New node: Dimensions (#2576)
* Add node for size of bounding box * Keep rustfmt happy --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
1 parent 9a62c1c commit a94354d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

node-graph/gcore/src/vector/vector_nodes.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,16 @@ async fn bounding_box(_: impl Ctx, vector_data: VectorDataTable) -> VectorDataTa
954954
result
955955
}
956956

957+
#[node_macro::node(category("Vector"), path(graphene_core::vector))]
958+
async fn dimensions(_: impl Ctx, vector_data: VectorDataTable) -> DVec2 {
959+
let vector_data_transform = vector_data.transform();
960+
let vector_data = vector_data.one_instance().instance;
961+
vector_data
962+
.bounding_box_with_transform(vector_data_transform)
963+
.map(|[top_left, bottom_right]| bottom_right - top_left)
964+
.unwrap_or_default()
965+
}
966+
957967
#[node_macro::node(category("Vector"), path(graphene_core::vector), properties("offset_path_properties"))]
958968
async fn offset_path(_: impl Ctx, vector_data: VectorDataTable, distance: f64, line_join: LineJoin, #[default(4.)] miter_limit: f64) -> VectorDataTable {
959969
let vector_data_transform = vector_data.transform();

0 commit comments

Comments
 (0)