Skip to content

Allow the Fill tool to flood fill raster images #2519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

EllenGYY
Copy link
Contributor

@EllenGYY EllenGYY commented Apr 6, 2025

• Adds a “Raster Fill” node when the fill bucket tool is used on a raster layer.
• Non-destructive: deleting the node restores the image to its original state.
• Users can adjust the “tolerance” of color similarity, based on Euclidean distance in LAB color space (currently per-layer only).

Possible improvements:
• Allow users to adjust and delete individual fill operations on the same layer, including their respective tolerance settings.
• Add support for gradient fills.

raster-fill-demo

@Keavon Keavon force-pushed the master branch 3 times, most recently from aa7ff13 to e11b57a Compare April 6, 2025 11:41
@Keavon
Copy link
Member

Keavon commented Apr 8, 2025

Please fix the CI failure on the test messages::tool::tool_messages::fill_tool::test_fill::ignore_raster.

@Keavon Keavon changed the title Allow the fill bucket tool to fill a raster image Allow the Fill tool to flood fill raster images Apr 8, 2025
*self = Self { fills, start_pos, tolerance };
}

// TODO: Why do we overwrite the tolerance that we just set a couple lines above?
Copy link
Member

Choose a reason for hiding this comment

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

fills: Vec<F>,
/// The starting positions of the flood fill points in the layer's local coordinates.
positions: Vec<DVec2>,
// TODO: What is the range? I'd expect 0-255, but we should also rescale that to 0-1. But this crashes at larger values approaching 100. And tolerance should be per-position not global to the node.
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tolerance is calculated by the euclidean distance in the CIELAB colorspace, which is a perspecively correct way of measuring color difference. Although value of A and B is autually boundaryless, softwares usually use -128 to 128, and the L has a range of 0 to 100. I will look into it and fix the bugs that cause the crash.

@@ -71,37 +76,111 @@ enum FillToolFsmState {
Filling,
}

#[derive(Clone, Debug, Default)]
struct FillToolData {
Copy link
Member

Choose a reason for hiding this comment

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

We need to set the tolerance in the tool's control bar. It should range from 0 (only the identically colored pixels) to 1 (all pixels regardless of color). We should also have a checkbox for contiguous.

struct FillToolData {
fills: Vec<Fill>,
start_pos: Vec<DVec2>,
tolerance: f64,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
tolerance: f64,
tolerance: Vec<f64>,

@Keavon Keavon marked this pull request as draft April 13, 2025 10:28
@Keavon
Copy link
Member

Keavon commented Apr 23, 2025

Checking in @EllenGYY.

@EllenGYY
Copy link
Contributor Author

@Keavon As the semester is approaching its final weeks and I have several project / research deadlines, I’ll revisit and improve this function’s behavior after my finals on May 1st.

@Keavon
Copy link
Member

Keavon commented Apr 23, 2025

Sounds good, thank you for the update.

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.

2 participants