Drawpile icon indicating copy to clipboard operation
Drawpile copied to clipboard

Flood fill: allow negative expand values

Open askmeaboutlo0m opened this issue 2 years ago • 0 comments

It should contract the filled area, instead of expanding it. This should be reasonably simple to implement, since contracting the filled area just means expanding the unfilled area, so the algorithm is the same.

The following changes need to be made:

  • In flood_fill.c:
    • DP_flood_fill currently clamps expand to a minimum of 0 when it calls make_mask. That needs to be removed.
    • make_mask should not add/subtract the expand value to/from the mask size when it's negative. It should just leave it as-is.
    • make_mask needs to use the absolute value of expand when generating the expansion kernel.
    • apply_expansion_kernel needs to invert the values when the expansion is negative. The mask uses values between 0.0 and 1.0, so inverting a value x means doing 1.0 - x.
  • In fillsettings.ui:
    • The minimum property of the expand slider needs to be set to -30. This can either be done using Qt Designer or by just editing the XML directly.
  • In fillsettings.cpp:
    • The expand tool property needs to be changed to allow values from -30 to 30. Currently it goes from 0 to 100 for some reason, even though you can't select higher values than 30.

Credit Meru for suggesting in the Changelog.

askmeaboutlo0m avatar Mar 21 '24 20:03 askmeaboutlo0m