Skip to content

Add combined parameter to box_warp function#3553

Open
mathurojus wants to merge 4 commits intoGraphiteEditor:masterfrom
mathurojus:mathurojus-patch-1
Open

Add combined parameter to box_warp function#3553
mathurojus wants to merge 4 commits intoGraphiteEditor:masterfrom
mathurojus:mathurojus-patch-1

Conversation

@mathurojus
Copy link

@mathurojus mathurojus commented Dec 31, 2025

Adds a combined parameter to control whether the box warp treats all subpaths as a single object (when true) or warps them individually (when false).

Fixes #3551

@mathurojus
Copy link
Author

@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> {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

};

// Compute combined bounding box if needed
let combined_bbox = if combined {
Copy link
Contributor

@Ayush2k02 Ayush2k02 Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

@mathurojus mathurojus Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Box warp doesn't treat subpaths as unified object

2 participants