Skip to content

Draft: Add "select all until color" selection methods to fill and contiguous selection tools

This MR adds new ways of selecting the region when using the flood fill, and adds the possibility of using the functionality with the fill and contiguous selection tools.

I had to implement these flood fill additions for the enclose and fill tool I'm making. But I thought that it could be a matter of time that users asked for some of this functionality for the fill tool, so I just implemented it in those tools for that reason and also because it will make the review of the enclose and fill tool easier.

These flood fill additions consist of:

  • new selection policies (actually one, with its hard/soft/extended variants) which alow to select all pixels as long as they are not similar to a predefined reference color. This allows to fill for example until the black lines of a line art, even if the colors between lines are not uniform.
  • new difference policy (slow/optimized) that calculates the minimum difference between the current pixel and a reference color and between the current pixel and a virtual fully transparent color.

Those additions may seem a bit strange and random here, in the context of the fill and contiguous selection tools. I think that they become clear just by the explanation given in the enclose and fill proposal, section 4.2.3.2.

To make use of those new flood fill policies, a new option is added to the fill and contiguous selection tools, called region selection. It consists of a combo box with the following options:

  • Select similar pixels. This is the default and is just the old, classic behavior where the contiguous pixels that are similar to the pixel at the seed position are selected.
  • Select all pixels until X. These methods use the new policies and they will select all the contiguous pixels, starting from the seed position, as long as the pixels are not similar to X, where X can be one of three options: a specific color, a fully transparent color, or both. The users can choose the color with a button next to the combo box:
    • Select all pixels until a specific color. This selects all pixels as long as they are not similar to the user defined color.
      ffi2_01
    • Select all pixels until transparent. This selects all pixels as long as they are not similar to transparent. This option is there because the color selector only allows to select solid colors, and to avoid adding an opacity slider. Internally works like the previous option, but with a transparent KoColor.
      ffi2_02
    • Select all pixels until a specific color or transparent. This selects all pixels as long as they are not similar to the user selected color or transparent. This option is mainly for some corner cases where the user wants to have as a limit the color but also the transparent pixels.
      ffi2_03

One usefull usecase is to use the eraser mode with the new options to clean up line drawings:
ffi2_04

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.

Merge request reports