Add combined parameter to box_warp function#3553
Add combined parameter to box_warp function#3553mathurojus wants to merge 4 commits intoGraphiteEditor:masterfrom
Conversation
|
@Keavon could you please approve the workflows when ready? If everything looks good, feel free to merge. Thanks! |
Added logic to compute combined bounding box for vectors.
|
|
||
| #[node_macro::node(category("Vector: Modifier"), path(core_types::vector))] | ||
| async fn box_warp(_: impl Ctx, content: Table<Vector>, #[expose] rectangle: Table<Vector>) -> Table<Vector> { | ||
| async fn box_warp(_: impl Ctx, content: Table<Vector>, #[expose] rectangle: Table<Vector>, #[expose] combined: bool) -> Table<Vector> { |
There was a problem hiding this comment.
@0HyperCube
Added the implementation for the combined parameter. When combined=true, the function now computes a unified bounding box for all vectors and applies the warp uniformly. When combined=false, it uses individual bounding boxes (original behavior).
Does this approach look correct?
124235a to
a42cad8
Compare
| }; | ||
|
|
||
| // Compute combined bounding box if needed | ||
| let combined_bbox = if combined { |
There was a problem hiding this comment.
consider using reduce here instead of fold
let combined_bbox = if combined {
content.iter()
.filter_map(|row| row.element.bounding_box_with_transform(row.transform))
.reduce(|[min, max], [bbox_min, bbox_max]| {
[min.min(bbox_min), max.max(bbox_max)]
})
} else {
None
};
since we are computing an optional aggregate here
this would eliminate the explicit Option type annotation
There was a problem hiding this comment.
@Ayush2k02 I've implemented your suggestion to use reduce instead of fold for the combined_bbox calculation.
Does this look good to you? Any feedback or additional changes needed?
Adds a
combinedparameter to control whether the box warp treats all subpaths as a single object (when true) or warps them individually (when false).Fixes #3551